Re: [RFC PATCH] crypto: brcm - explicitly cast cipher to hash type

2018-03-28 Thread Raveendra Padasalagi
Hi Stefan,

The change looks to be fine.  From the IP point of view its using the
same values in case of AES cipher and hash types so explicit casting
should be ok.

-Raveendra

On Sat, Mar 24, 2018 at 4:32 PM, Stefan Agner  wrote:
> In the AES cases enum spu_cipher_type and enum hash_type have
> the same values, so the assignment is fine. Explicitly cast
> the enum type conversion.
>
> This fixes two warnings when building with clang:
>   drivers/crypto/bcm/cipher.c:821:34: warning: implicit conversion from
>   enumeration type 'enum spu_cipher_type' to different enumeration
>   type 'enum hash_type' [-Wenum-conversion]
> hash_parms.type = cipher_parms.type;
> ~ ~^~~~
>   drivers/crypto/bcm/cipher.c:1412:26: warning: implicit conversion from
>   enumeration type 'enum spu_cipher_type' to different enumeration
>   type 'enum hash_type' [-Wenum-conversion]
> hash_parms.type = ctx->cipher_type;
> ~ ~^~~
>
> Signed-off-by: Stefan Agner 
> ---
> I am not familar with the IP... I would be glad if somebody with
> better insight could have a look whether that patch makes sense.
>
>  drivers/crypto/bcm/cipher.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
> index 2b75f95bbe1b..309c67c7012f 100644
> --- a/drivers/crypto/bcm/cipher.c
> +++ b/drivers/crypto/bcm/cipher.c
> @@ -818,7 +818,7 @@ static int handle_ahash_req(struct iproc_reqctx_s *rctx)
>
> /* AES hashing keeps key size in type field, so need to copy it here 
> */
> if (hash_parms.alg == HASH_ALG_AES)
> -   hash_parms.type = cipher_parms.type;
> +   hash_parms.type = (enum hash_type)cipher_parms.type;
> else
> hash_parms.type = spu->spu_hash_type(rctx->total_sent);
>
> @@ -1409,7 +1409,7 @@ static int handle_aead_req(struct iproc_reqctx_s *rctx)
> rctx->iv_ctr_len);
>
> if (ctx->auth.alg == HASH_ALG_AES)
> -   hash_parms.type = ctx->cipher_type;
> +   hash_parms.type = (enum hash_type)ctx->cipher_type;
>
> /* General case AAD padding (CCM and RFC4543 special cases below) */
> aead_parms.aad_pad_len = spu->spu_gcm_ccm_pad_len(ctx->cipher.mode,
> --
> 2.16.2
>


Re: [RFC PATCH] crypto: brcm - explicitly cast cipher to hash type

2018-03-28 Thread Raveendra Padasalagi
Hi Stefan,

The change looks to be fine.  From the IP point of view its using the
same values in case of AES cipher and hash types so explicit casting
should be ok.

-Raveendra

On Sat, Mar 24, 2018 at 4:32 PM, Stefan Agner  wrote:
> In the AES cases enum spu_cipher_type and enum hash_type have
> the same values, so the assignment is fine. Explicitly cast
> the enum type conversion.
>
> This fixes two warnings when building with clang:
>   drivers/crypto/bcm/cipher.c:821:34: warning: implicit conversion from
>   enumeration type 'enum spu_cipher_type' to different enumeration
>   type 'enum hash_type' [-Wenum-conversion]
> hash_parms.type = cipher_parms.type;
> ~ ~^~~~
>   drivers/crypto/bcm/cipher.c:1412:26: warning: implicit conversion from
>   enumeration type 'enum spu_cipher_type' to different enumeration
>   type 'enum hash_type' [-Wenum-conversion]
> hash_parms.type = ctx->cipher_type;
> ~ ~^~~
>
> Signed-off-by: Stefan Agner 
> ---
> I am not familar with the IP... I would be glad if somebody with
> better insight could have a look whether that patch makes sense.
>
>  drivers/crypto/bcm/cipher.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
> index 2b75f95bbe1b..309c67c7012f 100644
> --- a/drivers/crypto/bcm/cipher.c
> +++ b/drivers/crypto/bcm/cipher.c
> @@ -818,7 +818,7 @@ static int handle_ahash_req(struct iproc_reqctx_s *rctx)
>
> /* AES hashing keeps key size in type field, so need to copy it here 
> */
> if (hash_parms.alg == HASH_ALG_AES)
> -   hash_parms.type = cipher_parms.type;
> +   hash_parms.type = (enum hash_type)cipher_parms.type;
> else
> hash_parms.type = spu->spu_hash_type(rctx->total_sent);
>
> @@ -1409,7 +1409,7 @@ static int handle_aead_req(struct iproc_reqctx_s *rctx)
> rctx->iv_ctr_len);
>
> if (ctx->auth.alg == HASH_ALG_AES)
> -   hash_parms.type = ctx->cipher_type;
> +   hash_parms.type = (enum hash_type)ctx->cipher_type;
>
> /* General case AAD padding (CCM and RFC4543 special cases below) */
> aead_parms.aad_pad_len = spu->spu_gcm_ccm_pad_len(ctx->cipher.mode,
> --
> 2.16.2
>


Re: [PATCH 4.13 07/28] crypto: brcm - Explicity ACK mailbox message

2017-11-21 Thread Raveendra Padasalagi
Hi Greg,

Thanks for notifying the issue. This patch is supposed to be applied
on top of the below patch

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v4.14=9166c44358346c0a92b11fd4e24925efff791648

which is not present in stable, I missed to keep stable mailing list
in cc when this patch sent.
It's ok if you drop this patch for now in 4.13-stable.

For 4.14 stable release we need the current patch and the dependent
patch is already present in 4.14.

Regards,
Raveendra
On Tue, Nov 21, 2017 at 1:21 PM, Greg Kroah-Hartman
<gre...@linuxfoundation.org> wrote:
> Nope, this patch breaks the build as it relies on a previous patch that
> is not in 4.13-stable, so I'm dropping it.  If anyone wants it there,
> well, it really feels like it shouldn't be included in a stable tree
> anyway...
>
> thanks,
>
> greg k-h
>
> On Sun, Nov 19, 2017 at 03:43:54PM +0100, Greg Kroah-Hartman wrote:
>> 4.13-stable review patch.  If anyone has any objections, please let me know.
>>
>> --
>>
>> From: raveendra padasalagi <raveendra.padasal...@broadcom.com>
>>
>> commit f0e2ce58f853634d7ad1a418a49bd5fbd556227c upstream.
>>
>> Add support to explicity ACK mailbox message
>> because after sending message we can know
>> the send status via error attribute of brcm_message.
>>
>> This is needed to support "txdone_ack" supported in
>> mailbox controller driver.
>>
>> Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
>> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
>> Reviewed-by: Anup Patel <anup.pa...@broadcom.com>
>> Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
>> Signed-off-by: Herbert Xu <herb...@gondor.apana.org.au>
>> Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>
>>
>> ---
>>  drivers/crypto/bcm/cipher.c |  101 
>> 
>>  1 file changed, 46 insertions(+), 55 deletions(-)
>>
>> --- a/drivers/crypto/bcm/cipher.c
>> +++ b/drivers/crypto/bcm/cipher.c
>> @@ -258,6 +258,44 @@ spu_ablkcipher_tx_sg_create(struct brcm_
>>   return 0;
>>  }
>>
>> +static int mailbox_send_message(struct brcm_message *mssg, u32 flags,
>> + u8 chan_idx)
>> +{
>> + int err;
>> + int retry_cnt = 0;
>> + struct device *dev = &(iproc_priv.pdev->dev);
>> +
>> + err = mbox_send_message(iproc_priv.mbox[chan_idx], mssg);
>> + if (flags & CRYPTO_TFM_REQ_MAY_SLEEP) {
>> + while ((err == -ENOBUFS) && (retry_cnt < SPU_MB_RETRY_MAX)) {
>> + /*
>> +  * Mailbox queue is full. Since MAY_SLEEP is set, 
>> assume
>> +  * not in atomic context and we can wait and try again.
>> +  */
>> + retry_cnt++;
>> + usleep_range(MBOX_SLEEP_MIN, MBOX_SLEEP_MAX);
>> + err = mbox_send_message(iproc_priv.mbox[chan_idx],
>> + mssg);
>> + atomic_inc(_priv.mb_no_spc);
>> + }
>> + }
>> + if (err < 0) {
>> + atomic_inc(_priv.mb_send_fail);
>> + return err;
>> + }
>> +
>> + /* Check error returned by mailbox controller */
>> + err = mssg->error;
>> + if (unlikely(err < 0)) {
>> + dev_err(dev, "message error %d", err);
>> + /* Signal txdone for mailbox channel */
>> + }
>> +
>> + /* Signal txdone for mailbox channel */
>> + mbox_client_txdone(iproc_priv.mbox[chan_idx], err);
>> + return err;
>> +}
>> +
>>  /**
>>   * handle_ablkcipher_req() - Submit as much of a block cipher request as 
>> fits in
>>   * a single SPU request message, starting at the current position in the 
>> request
>> @@ -295,7 +333,6 @@ static int handle_ablkcipher_req(struct
>>   u32 pad_len;/* total length of all padding */
>>   bool update_key = false;
>>   struct brcm_message *mssg;  /* mailbox message */
>> - int retry_cnt = 0;
>>
>>   /* number of entries in src and dst sg in mailbox message. */
>>   u8 rx_frag_num = 2; /* response header and STATUS */
>> @@ -464,24 +501,9 @@ static int handle_ablkcipher_req(struct
>>   if (err)
>>   return err;
>>
>> - e

Re: [PATCH 4.13 07/28] crypto: brcm - Explicity ACK mailbox message

2017-11-21 Thread Raveendra Padasalagi
Hi Greg,

Thanks for notifying the issue. This patch is supposed to be applied
on top of the below patch

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v4.14=9166c44358346c0a92b11fd4e24925efff791648

which is not present in stable, I missed to keep stable mailing list
in cc when this patch sent.
It's ok if you drop this patch for now in 4.13-stable.

For 4.14 stable release we need the current patch and the dependent
patch is already present in 4.14.

Regards,
Raveendra
On Tue, Nov 21, 2017 at 1:21 PM, Greg Kroah-Hartman
 wrote:
> Nope, this patch breaks the build as it relies on a previous patch that
> is not in 4.13-stable, so I'm dropping it.  If anyone wants it there,
> well, it really feels like it shouldn't be included in a stable tree
> anyway...
>
> thanks,
>
> greg k-h
>
> On Sun, Nov 19, 2017 at 03:43:54PM +0100, Greg Kroah-Hartman wrote:
>> 4.13-stable review patch.  If anyone has any objections, please let me know.
>>
>> ------
>>
>> From: raveendra padasalagi 
>>
>> commit f0e2ce58f853634d7ad1a418a49bd5fbd556227c upstream.
>>
>> Add support to explicity ACK mailbox message
>> because after sending message we can know
>> the send status via error attribute of brcm_message.
>>
>> This is needed to support "txdone_ack" supported in
>> mailbox controller driver.
>>
>> Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
>> Signed-off-by: Raveendra Padasalagi 
>> Reviewed-by: Anup Patel 
>> Reviewed-by: Scott Branden 
>> Signed-off-by: Herbert Xu 
>> Signed-off-by: Greg Kroah-Hartman 
>>
>> ---
>>  drivers/crypto/bcm/cipher.c |  101 
>> 
>>  1 file changed, 46 insertions(+), 55 deletions(-)
>>
>> --- a/drivers/crypto/bcm/cipher.c
>> +++ b/drivers/crypto/bcm/cipher.c
>> @@ -258,6 +258,44 @@ spu_ablkcipher_tx_sg_create(struct brcm_
>>   return 0;
>>  }
>>
>> +static int mailbox_send_message(struct brcm_message *mssg, u32 flags,
>> + u8 chan_idx)
>> +{
>> + int err;
>> + int retry_cnt = 0;
>> + struct device *dev = &(iproc_priv.pdev->dev);
>> +
>> + err = mbox_send_message(iproc_priv.mbox[chan_idx], mssg);
>> + if (flags & CRYPTO_TFM_REQ_MAY_SLEEP) {
>> + while ((err == -ENOBUFS) && (retry_cnt < SPU_MB_RETRY_MAX)) {
>> + /*
>> +  * Mailbox queue is full. Since MAY_SLEEP is set, 
>> assume
>> +  * not in atomic context and we can wait and try again.
>> +  */
>> + retry_cnt++;
>> + usleep_range(MBOX_SLEEP_MIN, MBOX_SLEEP_MAX);
>> + err = mbox_send_message(iproc_priv.mbox[chan_idx],
>> + mssg);
>> + atomic_inc(_priv.mb_no_spc);
>> + }
>> + }
>> + if (err < 0) {
>> + atomic_inc(_priv.mb_send_fail);
>> + return err;
>> + }
>> +
>> + /* Check error returned by mailbox controller */
>> + err = mssg->error;
>> + if (unlikely(err < 0)) {
>> + dev_err(dev, "message error %d", err);
>> + /* Signal txdone for mailbox channel */
>> + }
>> +
>> + /* Signal txdone for mailbox channel */
>> + mbox_client_txdone(iproc_priv.mbox[chan_idx], err);
>> + return err;
>> +}
>> +
>>  /**
>>   * handle_ablkcipher_req() - Submit as much of a block cipher request as 
>> fits in
>>   * a single SPU request message, starting at the current position in the 
>> request
>> @@ -295,7 +333,6 @@ static int handle_ablkcipher_req(struct
>>   u32 pad_len;/* total length of all padding */
>>   bool update_key = false;
>>   struct brcm_message *mssg;  /* mailbox message */
>> - int retry_cnt = 0;
>>
>>   /* number of entries in src and dst sg in mailbox message. */
>>   u8 rx_frag_num = 2; /* response header and STATUS */
>> @@ -464,24 +501,9 @@ static int handle_ablkcipher_req(struct
>>   if (err)
>>   return err;
>>
>> - err = mbox_send_message(iproc_priv.mbox[rctx->chan_idx], mssg);
>> - if (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) {
>> - while ((err == -ENOBUFS) && (retry_cnt < SPU_MB_RETRY_MAX)) {
>> - /*
>>

Re: [PATCH v2 1/3] dt-bindings: phy: Add Cygnus usb phy binding

2017-11-13 Thread Raveendra Padasalagi
Hi Rob,

On Mon, Nov 13, 2017 at 11:23 PM, Rob Herring <r...@kernel.org> wrote:
> On Sun, Nov 12, 2017 at 10:23 PM, Raveendra Padasalagi
> <raveendra.padasal...@broadcom.com> wrote:
>> Hi,
>>
>> On Sat, Nov 11, 2017 at 3:14 AM, Rob Herring <r...@kernel.org> wrote:
>>> On Wed, Nov 08, 2017 at 01:16:41PM +0530, Raveendra Padasalagi wrote:
>>>> Add devicetree binding document for broadcom's
>>>> Cygnus SoC specific usb phy controller driver.
>>>>
>>>> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
>>>> ---
>>>>  .../bindings/phy/brcm,cygnus-usb-phy.txt   | 106 
>>>> +
>>>>  1 file changed, 106 insertions(+)
>>>>  create mode 100644 
>>>> Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt 
>>>> b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>>>> new file mode 100644
>>>> index 000..bbc4b94
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>>>> @@ -0,0 +1,106 @@
>>>> +BROADCOM CYGNUS USB PHY
>>>> +
>>>> +Required Properties:
>>>> +- compatible:  brcm,cygnus-usb-phy
>>>> +- reg : the register start address and length for
>>>> +crmu_usbphy_aon_ctrl,
>>>> +cdru usb phy control,
>>>> +usb host idm registers,
>>>> +usb device idm registers.
>>>> +- reg-names: a list of the names corresponding to the previous register 
>>>> ranges
>>>> +  Should contain
>>>> +"crmu-usbphy-aon-ctrl",
>>>> +"cdru-usbphy",
>>>> +"usb2h-idm",
>>>> +"usb2d-idm".
>>>> +- address-cells: should be 1
>>>> +- size-cells: should be 0
>>>> +
>>>> +Sub-nodes:
>>>> +  Each port's PHY should be represented as a sub-node.
>>>> +
>>>> +Sub-nodes required properties:
>>>> +- reg: the PHY number
>>>> +- #phy-cells must be 1
>>>> +  The node that uses the phy must provide 1 integer argument specifying
>>>> +  port number.
>>>> +
>>>> +Optional Properties:
>>>> +- vbus-p#-supply : The regulator for vbus out control for the host
>>>
>>> Is this a literal # or something else?
>>
>> Yes, this is a literal. It's assumed # will replace numeric 0-2 for
>> each of the ports.
>
> I'm still confused. Which is valid? "vbus-p#-supply" or "vbus-p0-supply"
>
I agree, it's creating confusion. Instead of enumerating
"vbus-p0-supply", "vbus-p1-supply", "vbus-p2-supply" kept "vbus-p#-supply".

Yes, as suggested by you "vbus-supply" should be sufficient as it's in each
of phy sub node.

> If the latter, you need to enumerate all valid options. But these are
> in sub nodes for each port, so just "vbus-supply" should be
> sufficient.

Keeping "vbus-supply" should not create any confusion. Will send out the
change in next version of the patch.

> One more question, does Vbus actually supply power to the phy or you
> are just associating the Vbus supply to a connector with a port? The
> latter needs a connector node instead and Vbus should be part of that.
> There's been some attempts at USB connectors, but we don't really have
> one yet (the extcon binding is not it).

Vbus is not supplied to phy, it's been given to the devices connected on
the port and in our platform vbus is controlled through an external regulator
which is controlled through gpio.
So "vbus-supply" shown above actually points to the phandle of vbus regulator
node.

>> In the example it's not shown as the regulators specified in vbus-p#-supply
>> are board specific.
>
> Please show in the example. Examples should be complete.

Ok. Sure.

> Rob


Re: [PATCH v2 1/3] dt-bindings: phy: Add Cygnus usb phy binding

2017-11-13 Thread Raveendra Padasalagi
Hi Rob,

On Mon, Nov 13, 2017 at 11:23 PM, Rob Herring  wrote:
> On Sun, Nov 12, 2017 at 10:23 PM, Raveendra Padasalagi
>  wrote:
>> Hi,
>>
>> On Sat, Nov 11, 2017 at 3:14 AM, Rob Herring  wrote:
>>> On Wed, Nov 08, 2017 at 01:16:41PM +0530, Raveendra Padasalagi wrote:
>>>> Add devicetree binding document for broadcom's
>>>> Cygnus SoC specific usb phy controller driver.
>>>>
>>>> Signed-off-by: Raveendra Padasalagi 
>>>> ---
>>>>  .../bindings/phy/brcm,cygnus-usb-phy.txt   | 106 
>>>> +
>>>>  1 file changed, 106 insertions(+)
>>>>  create mode 100644 
>>>> Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt 
>>>> b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>>>> new file mode 100644
>>>> index 000..bbc4b94
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>>>> @@ -0,0 +1,106 @@
>>>> +BROADCOM CYGNUS USB PHY
>>>> +
>>>> +Required Properties:
>>>> +- compatible:  brcm,cygnus-usb-phy
>>>> +- reg : the register start address and length for
>>>> +crmu_usbphy_aon_ctrl,
>>>> +cdru usb phy control,
>>>> +usb host idm registers,
>>>> +usb device idm registers.
>>>> +- reg-names: a list of the names corresponding to the previous register 
>>>> ranges
>>>> +  Should contain
>>>> +"crmu-usbphy-aon-ctrl",
>>>> +"cdru-usbphy",
>>>> +"usb2h-idm",
>>>> +"usb2d-idm".
>>>> +- address-cells: should be 1
>>>> +- size-cells: should be 0
>>>> +
>>>> +Sub-nodes:
>>>> +  Each port's PHY should be represented as a sub-node.
>>>> +
>>>> +Sub-nodes required properties:
>>>> +- reg: the PHY number
>>>> +- #phy-cells must be 1
>>>> +  The node that uses the phy must provide 1 integer argument specifying
>>>> +  port number.
>>>> +
>>>> +Optional Properties:
>>>> +- vbus-p#-supply : The regulator for vbus out control for the host
>>>
>>> Is this a literal # or something else?
>>
>> Yes, this is a literal. It's assumed # will replace numeric 0-2 for
>> each of the ports.
>
> I'm still confused. Which is valid? "vbus-p#-supply" or "vbus-p0-supply"
>
I agree, it's creating confusion. Instead of enumerating
"vbus-p0-supply", "vbus-p1-supply", "vbus-p2-supply" kept "vbus-p#-supply".

Yes, as suggested by you "vbus-supply" should be sufficient as it's in each
of phy sub node.

> If the latter, you need to enumerate all valid options. But these are
> in sub nodes for each port, so just "vbus-supply" should be
> sufficient.

Keeping "vbus-supply" should not create any confusion. Will send out the
change in next version of the patch.

> One more question, does Vbus actually supply power to the phy or you
> are just associating the Vbus supply to a connector with a port? The
> latter needs a connector node instead and Vbus should be part of that.
> There's been some attempts at USB connectors, but we don't really have
> one yet (the extcon binding is not it).

Vbus is not supplied to phy, it's been given to the devices connected on
the port and in our platform vbus is controlled through an external regulator
which is controlled through gpio.
So "vbus-supply" shown above actually points to the phandle of vbus regulator
node.

>> In the example it's not shown as the regulators specified in vbus-p#-supply
>> are board specific.
>
> Please show in the example. Examples should be complete.

Ok. Sure.

> Rob


Re: [PATCH v2 1/3] dt-bindings: phy: Add Cygnus usb phy binding

2017-11-12 Thread Raveendra Padasalagi
Hi,

On Sat, Nov 11, 2017 at 3:14 AM, Rob Herring <r...@kernel.org> wrote:
> On Wed, Nov 08, 2017 at 01:16:41PM +0530, Raveendra Padasalagi wrote:
>> Add devicetree binding document for broadcom's
>> Cygnus SoC specific usb phy controller driver.
>>
>> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
>> ---
>>  .../bindings/phy/brcm,cygnus-usb-phy.txt   | 106 
>> +
>>  1 file changed, 106 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>>
>> diff --git a/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt 
>> b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>> new file mode 100644
>> index 000..bbc4b94
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>> @@ -0,0 +1,106 @@
>> +BROADCOM CYGNUS USB PHY
>> +
>> +Required Properties:
>> +- compatible:  brcm,cygnus-usb-phy
>> +- reg : the register start address and length for
>> +crmu_usbphy_aon_ctrl,
>> +cdru usb phy control,
>> +usb host idm registers,
>> +usb device idm registers.
>> +- reg-names: a list of the names corresponding to the previous register 
>> ranges
>> +  Should contain
>> +"crmu-usbphy-aon-ctrl",
>> +"cdru-usbphy",
>> +"usb2h-idm",
>> +"usb2d-idm".
>> +- address-cells: should be 1
>> +- size-cells: should be 0
>> +
>> +Sub-nodes:
>> +  Each port's PHY should be represented as a sub-node.
>> +
>> +Sub-nodes required properties:
>> +- reg: the PHY number
>> +- #phy-cells must be 1
>> +  The node that uses the phy must provide 1 integer argument specifying
>> +  port number.
>> +
>> +Optional Properties:
>> +- vbus-p#-supply : The regulator for vbus out control for the host
>
> Is this a literal # or something else?

Yes, this is a literal. It's assumed # will replace numeric 0-2 for
each of the ports.
In the example it's not shown as the regulators specified in vbus-p#-supply
are board specific.

>> +  functionality enabled ports.
>> +- vbus-gpios: vbus gpio binding
>> +  This is mandatory for port 2, as port 2 is used as dual role phy.
>> +  Based on the vbus and id values device or host role is determined
>> +  for phy 2.
>
> These optional properties don't match with the example.
vbus-gpios is placed by mistake here in the documentation,
this is no more required. I will remove it in the next version of the patch.

>> +
>> +- extcon: extcon phandle
>> +  This is mandatory for port 2,  as port 2 is used as dual role phy.
>> +  extcon should be phandle to external usb gpio module which provide
>> +  device or host role notifications based on the ID and VBUS gpio's state.
>> +
>> +
>> +Refer to phy/phy-bindings.txt for the generic PHY binding properties
>> +
>> +NOTE: port 0 and port 1 are host only and port 2 is dual role port.
>> +
>> +Example of phy :
>> + usbphy: usb-phy@0301c028 {
>> + compatible = "brcm,cygnus-usb-phy";
>> + reg = <0x0301c028 0x4>,
>> +   <0x0301d1b4 0x5c>,
>> +   <0x18115000 0xa00>,
>> +   <0x18111000 0xa00>;
>> + reg-names = "crmu-usbphy-aon-ctrl", "cdru-usbphy",
>> + "usb2h-idm", "usb2d-idm";
>> + #address-cells = <1>;
>> + #size-cells = <0>;
>> +
>> + usbphy0: usb-phy@0 {
>> + reg = <0>;
>> + #phy-cells = <1>;
>> + };
>> +
>> + usbphy1: usb-phy@1 {
>> + reg = <1>;
>> + #phy-cells = <1>;
>> + };
>> +
>> + usbphy2: usb-phy@2 {
>> + reg = <2>;
>> + #phy-cells = <1>;
>> + extcon = <_usb>;
>> + };
>> + };
>> +
>> + extcon_usb: extcon_usb {
>> + compatible = "linux,extcon-usb-gpio";
>> + vbus-gpio = <_asiu 121 0>;
>> + id-gpio = <_asiu 122 0>;
>> + status = "okay";
>> + };
>> +
>> +
>> +Example of node using the phy:
>> +
>> + /* This nodes declares all three ports, port 0
>> + and port 1 are host and port 2 is device or host */
>> +
>> + ehci0: usb@18048000 {
>> + compatible = "generic-ehci";
>> + reg = <0x18048000 0x100>;
>> + interrupts = ;
>> + phys = < 0  1  2>;
>> + phy-names = "usbp0","usbp1","usbp2";
>> + status = "okay";
>
> Don't show status in examples.

Ok, Thanks. I will update it in the next version of the patch.

>> + };
>> +
>> + /* This node declares port 2 phy
>> + and configures it for device */
>> +
>> + usbd_udc_dwc1: usb@1804c000 {
>> + compatible = "iproc-udc";
>> + reg = <0x1804c000 0x2000>;
>> + interrupts = ;
>> + phys = < 2>;
>> + phy-names = "usbdrd";
>> + };
>> --
>> 1.9.1
>>


Re: [PATCH v2 1/3] dt-bindings: phy: Add Cygnus usb phy binding

2017-11-12 Thread Raveendra Padasalagi
Hi,

On Sat, Nov 11, 2017 at 3:14 AM, Rob Herring  wrote:
> On Wed, Nov 08, 2017 at 01:16:41PM +0530, Raveendra Padasalagi wrote:
>> Add devicetree binding document for broadcom's
>> Cygnus SoC specific usb phy controller driver.
>>
>> Signed-off-by: Raveendra Padasalagi 
>> ---
>>  .../bindings/phy/brcm,cygnus-usb-phy.txt   | 106 
>> +
>>  1 file changed, 106 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>>
>> diff --git a/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt 
>> b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>> new file mode 100644
>> index 000..bbc4b94
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>> @@ -0,0 +1,106 @@
>> +BROADCOM CYGNUS USB PHY
>> +
>> +Required Properties:
>> +- compatible:  brcm,cygnus-usb-phy
>> +- reg : the register start address and length for
>> +crmu_usbphy_aon_ctrl,
>> +cdru usb phy control,
>> +usb host idm registers,
>> +usb device idm registers.
>> +- reg-names: a list of the names corresponding to the previous register 
>> ranges
>> +  Should contain
>> +"crmu-usbphy-aon-ctrl",
>> +"cdru-usbphy",
>> +"usb2h-idm",
>> +"usb2d-idm".
>> +- address-cells: should be 1
>> +- size-cells: should be 0
>> +
>> +Sub-nodes:
>> +  Each port's PHY should be represented as a sub-node.
>> +
>> +Sub-nodes required properties:
>> +- reg: the PHY number
>> +- #phy-cells must be 1
>> +  The node that uses the phy must provide 1 integer argument specifying
>> +  port number.
>> +
>> +Optional Properties:
>> +- vbus-p#-supply : The regulator for vbus out control for the host
>
> Is this a literal # or something else?

Yes, this is a literal. It's assumed # will replace numeric 0-2 for
each of the ports.
In the example it's not shown as the regulators specified in vbus-p#-supply
are board specific.

>> +  functionality enabled ports.
>> +- vbus-gpios: vbus gpio binding
>> +  This is mandatory for port 2, as port 2 is used as dual role phy.
>> +  Based on the vbus and id values device or host role is determined
>> +  for phy 2.
>
> These optional properties don't match with the example.
vbus-gpios is placed by mistake here in the documentation,
this is no more required. I will remove it in the next version of the patch.

>> +
>> +- extcon: extcon phandle
>> +  This is mandatory for port 2,  as port 2 is used as dual role phy.
>> +  extcon should be phandle to external usb gpio module which provide
>> +  device or host role notifications based on the ID and VBUS gpio's state.
>> +
>> +
>> +Refer to phy/phy-bindings.txt for the generic PHY binding properties
>> +
>> +NOTE: port 0 and port 1 are host only and port 2 is dual role port.
>> +
>> +Example of phy :
>> + usbphy: usb-phy@0301c028 {
>> + compatible = "brcm,cygnus-usb-phy";
>> + reg = <0x0301c028 0x4>,
>> +   <0x0301d1b4 0x5c>,
>> +   <0x18115000 0xa00>,
>> +   <0x18111000 0xa00>;
>> + reg-names = "crmu-usbphy-aon-ctrl", "cdru-usbphy",
>> + "usb2h-idm", "usb2d-idm";
>> + #address-cells = <1>;
>> + #size-cells = <0>;
>> +
>> + usbphy0: usb-phy@0 {
>> + reg = <0>;
>> + #phy-cells = <1>;
>> + };
>> +
>> + usbphy1: usb-phy@1 {
>> + reg = <1>;
>> + #phy-cells = <1>;
>> + };
>> +
>> + usbphy2: usb-phy@2 {
>> + reg = <2>;
>> + #phy-cells = <1>;
>> + extcon = <_usb>;
>> + };
>> + };
>> +
>> + extcon_usb: extcon_usb {
>> + compatible = "linux,extcon-usb-gpio";
>> + vbus-gpio = <_asiu 121 0>;
>> + id-gpio = <_asiu 122 0>;
>> + status = "okay";
>> + };
>> +
>> +
>> +Example of node using the phy:
>> +
>> + /* This nodes declares all three ports, port 0
>> + and port 1 are host and port 2 is device or host */
>> +
>> + ehci0: usb@18048000 {
>> + compatible = "generic-ehci";
>> + reg = <0x18048000 0x100>;
>> + interrupts = ;
>> + phys = < 0  1  2>;
>> + phy-names = "usbp0","usbp1","usbp2";
>> + status = "okay";
>
> Don't show status in examples.

Ok, Thanks. I will update it in the next version of the patch.

>> + };
>> +
>> + /* This node declares port 2 phy
>> + and configures it for device */
>> +
>> + usbd_udc_dwc1: usb@1804c000 {
>> + compatible = "iproc-udc";
>> + reg = <0x1804c000 0x2000>;
>> + interrupts = ;
>> + phys = < 2>;
>> + phy-names = "usbdrd";
>> + };
>> --
>> 1.9.1
>>


Re: [PATCH v2 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-11-08 Thread Raveendra Padasalagi
Hi,

On Wed, Nov 8, 2017 at 4:06 PM, Chanwoo Choi <cw00.c...@samsung.com> wrote:
> Hi,
>
> On 2017년 11월 08일 16:52, Raveendra Padasalagi wrote:
>> Hi,
>>
>> Adding Chanwoo Choi to review extcon API's.
>>
>> -Raveendra
>> On Wed, Nov 8, 2017 at 1:16 PM, Raveendra Padasalagi
>> <raveendra.padasal...@broadcom.com> wrote:
>>> Add driver for Broadcom's USB phy controller's used in Cygnus
>>> familyof SoC. Cygnus has three USB phy controller's, port 0,
>>> port 1 provides USB host functionality and port 2 can be configured
>>> for host/device role.
>>>
>>> Configuration of host/device role for port 2 is achieved based on
>>> the extcon events, the driver registers to extcon framework to get
>>> appropriate connect events for Host/Device cables connect/disconnect
>>> states based on VBUS and ID interrupts.
>>>
>>> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
>>> ---
>>>  drivers/phy/broadcom/Kconfig  |  14 +
>>>  drivers/phy/broadcom/Makefile |   1 +
>>>  drivers/phy/broadcom/phy-bcm-cygnus-usb.c | 690 
>>> ++
>>>  3 files changed, 705 insertions(+)
>>>  create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>>
>>> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
>>> index 64fc59c..3179daf 100644
>>> --- a/drivers/phy/broadcom/Kconfig
>>> +++ b/drivers/phy/broadcom/Kconfig
>>> @@ -1,6 +1,20 @@
>>>  #
>>>  # Phy drivers for Broadcom platforms
>>>  #
>>> +config PHY_BCM_CYGNUS_USB
>>> +   tristate "Broadcom Cygnus USB PHY support"
>>> +   depends on OF
>>> +   depends on ARCH_BCM_CYGNUS || COMPILE_TEST
>>> +   select GENERIC_PHY
>>> +   select EXTCON_USB_GPIO
>
> As I commented on v1 patch, it is not proper to select the specific
> device driver. Instead, you should select the framework as following:
>
> select EXTCON
>
> And if you want to enable the specific device driver,
> you need to add the configuration to the config file
> (such as arch/arm64/configs/*defconfig).
>
Ok, Got confused with the suggestion on previous patch.
Without selecting EXTCON_USB_GPIO, "linux,usb-gpio" driver was not
getting enabled in the build.

It's clear now, I will keep "select EXTCON"  in this Kconfig and send
another patch to enable
EXTCON_USB_GPIO in required defconfig.

>>> +   default ARCH_BCM_CYGNUS
>>> +   help
>>> + Enable this to support three USB PHY's present in Broadcom's
>>> + Cygnus chip.
>>> +
>>> + The phys are capable of supporting host mode on all ports and
>>> + device mode for port 2.
>>> +
>>>  config PHY_CYGNUS_PCIE
>>> tristate "Broadcom Cygnus PCIe PHY driver"
>>> depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
>>> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
>>> index 4eb82ec..3dec23c 100644
>>> --- a/drivers/phy/broadcom/Makefile
>>> +++ b/drivers/phy/broadcom/Makefile
>>> @@ -1,4 +1,5 @@
>>>  obj-$(CONFIG_PHY_CYGNUS_PCIE)  += phy-bcm-cygnus-pcie.o
>>> +obj-$(CONFIG_PHY_BCM_CYGNUS_USB)   += phy-bcm-cygnus-usb.o
>>>  obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
>>>  obj-$(CONFIG_PHY_BCM_NS_USB2)  += phy-bcm-ns-usb2.o
>>>  obj-$(CONFIG_PHY_BCM_NS_USB3)  += phy-bcm-ns-usb3.o
>>> diff --git a/drivers/phy/broadcom/phy-bcm-cygnus-usb.c 
>>> b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>> new file mode 100644
>>> index 000..cf957d4
>>> --- /dev/null
>>> +++ b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>> @@ -0,0 +1,690 @@
>>> +/*
>>> + * Copyright 2017 Broadcom
>>> + *
>>> + * 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 (the "GPL").
>>> + *
>>> + * This program is distributed in the hope that it will be useful, but
>>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>>> + * General Public License version 2 (GPLv2) for more details.
>>> + *
>>> + * You should have received a copy of the GNU Gene

Re: [PATCH v2 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-11-08 Thread Raveendra Padasalagi
Hi,

On Wed, Nov 8, 2017 at 4:06 PM, Chanwoo Choi  wrote:
> Hi,
>
> On 2017년 11월 08일 16:52, Raveendra Padasalagi wrote:
>> Hi,
>>
>> Adding Chanwoo Choi to review extcon API's.
>>
>> -Raveendra
>> On Wed, Nov 8, 2017 at 1:16 PM, Raveendra Padasalagi
>>  wrote:
>>> Add driver for Broadcom's USB phy controller's used in Cygnus
>>> familyof SoC. Cygnus has three USB phy controller's, port 0,
>>> port 1 provides USB host functionality and port 2 can be configured
>>> for host/device role.
>>>
>>> Configuration of host/device role for port 2 is achieved based on
>>> the extcon events, the driver registers to extcon framework to get
>>> appropriate connect events for Host/Device cables connect/disconnect
>>> states based on VBUS and ID interrupts.
>>>
>>> Signed-off-by: Raveendra Padasalagi 
>>> ---
>>>  drivers/phy/broadcom/Kconfig  |  14 +
>>>  drivers/phy/broadcom/Makefile |   1 +
>>>  drivers/phy/broadcom/phy-bcm-cygnus-usb.c | 690 
>>> ++
>>>  3 files changed, 705 insertions(+)
>>>  create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>>
>>> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
>>> index 64fc59c..3179daf 100644
>>> --- a/drivers/phy/broadcom/Kconfig
>>> +++ b/drivers/phy/broadcom/Kconfig
>>> @@ -1,6 +1,20 @@
>>>  #
>>>  # Phy drivers for Broadcom platforms
>>>  #
>>> +config PHY_BCM_CYGNUS_USB
>>> +   tristate "Broadcom Cygnus USB PHY support"
>>> +   depends on OF
>>> +   depends on ARCH_BCM_CYGNUS || COMPILE_TEST
>>> +   select GENERIC_PHY
>>> +   select EXTCON_USB_GPIO
>
> As I commented on v1 patch, it is not proper to select the specific
> device driver. Instead, you should select the framework as following:
>
> select EXTCON
>
> And if you want to enable the specific device driver,
> you need to add the configuration to the config file
> (such as arch/arm64/configs/*defconfig).
>
Ok, Got confused with the suggestion on previous patch.
Without selecting EXTCON_USB_GPIO, "linux,usb-gpio" driver was not
getting enabled in the build.

It's clear now, I will keep "select EXTCON"  in this Kconfig and send
another patch to enable
EXTCON_USB_GPIO in required defconfig.

>>> +   default ARCH_BCM_CYGNUS
>>> +   help
>>> + Enable this to support three USB PHY's present in Broadcom's
>>> + Cygnus chip.
>>> +
>>> + The phys are capable of supporting host mode on all ports and
>>> + device mode for port 2.
>>> +
>>>  config PHY_CYGNUS_PCIE
>>> tristate "Broadcom Cygnus PCIe PHY driver"
>>> depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
>>> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
>>> index 4eb82ec..3dec23c 100644
>>> --- a/drivers/phy/broadcom/Makefile
>>> +++ b/drivers/phy/broadcom/Makefile
>>> @@ -1,4 +1,5 @@
>>>  obj-$(CONFIG_PHY_CYGNUS_PCIE)  += phy-bcm-cygnus-pcie.o
>>> +obj-$(CONFIG_PHY_BCM_CYGNUS_USB)   += phy-bcm-cygnus-usb.o
>>>  obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
>>>  obj-$(CONFIG_PHY_BCM_NS_USB2)  += phy-bcm-ns-usb2.o
>>>  obj-$(CONFIG_PHY_BCM_NS_USB3)  += phy-bcm-ns-usb3.o
>>> diff --git a/drivers/phy/broadcom/phy-bcm-cygnus-usb.c 
>>> b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>> new file mode 100644
>>> index 000..cf957d4
>>> --- /dev/null
>>> +++ b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>> @@ -0,0 +1,690 @@
>>> +/*
>>> + * Copyright 2017 Broadcom
>>> + *
>>> + * 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 (the "GPL").
>>> + *
>>> + * This program is distributed in the hope that it will be useful, but
>>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>>> + * General Public License version 2 (GPLv2) for more details.
>>> + *
>>> + * You should have received a copy of the GNU General Public License
>>> + * version 2 (GPLv2) along with this source code.
&g

Re: [PATCH v2 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-11-07 Thread Raveendra Padasalagi
Hi,

Adding Chanwoo Choi to review extcon API's.

-Raveendra
On Wed, Nov 8, 2017 at 1:16 PM, Raveendra Padasalagi
<raveendra.padasal...@broadcom.com> wrote:
> Add driver for Broadcom's USB phy controller's used in Cygnus
> familyof SoC. Cygnus has three USB phy controller's, port 0,
> port 1 provides USB host functionality and port 2 can be configured
> for host/device role.
>
> Configuration of host/device role for port 2 is achieved based on
> the extcon events, the driver registers to extcon framework to get
> appropriate connect events for Host/Device cables connect/disconnect
> states based on VBUS and ID interrupts.
>
> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
> ---
>  drivers/phy/broadcom/Kconfig  |  14 +
>  drivers/phy/broadcom/Makefile |   1 +
>  drivers/phy/broadcom/phy-bcm-cygnus-usb.c | 690 
> ++
>  3 files changed, 705 insertions(+)
>  create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>
> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
> index 64fc59c..3179daf 100644
> --- a/drivers/phy/broadcom/Kconfig
> +++ b/drivers/phy/broadcom/Kconfig
> @@ -1,6 +1,20 @@
>  #
>  # Phy drivers for Broadcom platforms
>  #
> +config PHY_BCM_CYGNUS_USB
> +   tristate "Broadcom Cygnus USB PHY support"
> +   depends on OF
> +   depends on ARCH_BCM_CYGNUS || COMPILE_TEST
> +   select GENERIC_PHY
> +   select EXTCON_USB_GPIO
> +   default ARCH_BCM_CYGNUS
> +   help
> + Enable this to support three USB PHY's present in Broadcom's
> + Cygnus chip.
> +
> + The phys are capable of supporting host mode on all ports and
> + device mode for port 2.
> +
>  config PHY_CYGNUS_PCIE
> tristate "Broadcom Cygnus PCIe PHY driver"
> depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
> index 4eb82ec..3dec23c 100644
> --- a/drivers/phy/broadcom/Makefile
> +++ b/drivers/phy/broadcom/Makefile
> @@ -1,4 +1,5 @@
>  obj-$(CONFIG_PHY_CYGNUS_PCIE)  += phy-bcm-cygnus-pcie.o
> +obj-$(CONFIG_PHY_BCM_CYGNUS_USB)   += phy-bcm-cygnus-usb.o
>  obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
>  obj-$(CONFIG_PHY_BCM_NS_USB2)  += phy-bcm-ns-usb2.o
>  obj-$(CONFIG_PHY_BCM_NS_USB3)  += phy-bcm-ns-usb3.o
> diff --git a/drivers/phy/broadcom/phy-bcm-cygnus-usb.c 
> b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
> new file mode 100644
> index 000..cf957d4
> --- /dev/null
> +++ b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
> @@ -0,0 +1,690 @@
> +/*
> + * Copyright 2017 Broadcom
> + *
> + * 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 (the "GPL").
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License version 2 (GPLv2) for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * version 2 (GPLv2) along with this source code.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* CDRU Block Register Offsets and bit definitions */
> +#define CDRU_USBPHY_CLK_RST_SEL_OFFSET 0x0
> +#define CDRU_USBPHY2_HOST_DEV_SEL_OFFSET   0x4
> +#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_OFFSET0x5C
> +#define CDRU_USBPHY_P0_STATUS_OFFSET   0x1C
> +#define CDRU_USBPHY_P1_STATUS_OFFSET   0x34
> +#define CDRU_USBPHY_P2_STATUS_OFFSET   0x4C
> +
> +#define CDRU_USBPHY_USBPHY_ILDO_ON_FLAGBIT(1)
> +#define CDRU_USBPHY_USBPHY_PLL_LOCKBIT(0)
> +#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_DISABLE   BIT(0)
> +
> +/* CRMU Block Register Offsets and bit definitions */
> +#define CRMU_USB_PHY_AON_CTRL_OFFSET   0x0
> +#define CRMU_USBPHY_P0_AFE_CORERDY_VDDCBIT(1)
> +#define CRMU_USBPHY_P0_RESETB  BIT(2)
> +#define CRMU_USBPHY_P1_AFE_CORERDY_VDDCBIT(9)
> +#define CRMU_USBPHY_P1_RESETB  BIT(10)
> +#define CRMU_USBPHY_P2_AFE_CORERDY_VDDC  

Re: [PATCH v2 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-11-07 Thread Raveendra Padasalagi
Hi,

Adding Chanwoo Choi to review extcon API's.

-Raveendra
On Wed, Nov 8, 2017 at 1:16 PM, Raveendra Padasalagi
 wrote:
> Add driver for Broadcom's USB phy controller's used in Cygnus
> familyof SoC. Cygnus has three USB phy controller's, port 0,
> port 1 provides USB host functionality and port 2 can be configured
> for host/device role.
>
> Configuration of host/device role for port 2 is achieved based on
> the extcon events, the driver registers to extcon framework to get
> appropriate connect events for Host/Device cables connect/disconnect
> states based on VBUS and ID interrupts.
>
> Signed-off-by: Raveendra Padasalagi 
> ---
>  drivers/phy/broadcom/Kconfig  |  14 +
>  drivers/phy/broadcom/Makefile |   1 +
>  drivers/phy/broadcom/phy-bcm-cygnus-usb.c | 690 
> ++
>  3 files changed, 705 insertions(+)
>  create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>
> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
> index 64fc59c..3179daf 100644
> --- a/drivers/phy/broadcom/Kconfig
> +++ b/drivers/phy/broadcom/Kconfig
> @@ -1,6 +1,20 @@
>  #
>  # Phy drivers for Broadcom platforms
>  #
> +config PHY_BCM_CYGNUS_USB
> +   tristate "Broadcom Cygnus USB PHY support"
> +   depends on OF
> +   depends on ARCH_BCM_CYGNUS || COMPILE_TEST
> +   select GENERIC_PHY
> +   select EXTCON_USB_GPIO
> +   default ARCH_BCM_CYGNUS
> +   help
> + Enable this to support three USB PHY's present in Broadcom's
> + Cygnus chip.
> +
> + The phys are capable of supporting host mode on all ports and
> + device mode for port 2.
> +
>  config PHY_CYGNUS_PCIE
> tristate "Broadcom Cygnus PCIe PHY driver"
> depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
> index 4eb82ec..3dec23c 100644
> --- a/drivers/phy/broadcom/Makefile
> +++ b/drivers/phy/broadcom/Makefile
> @@ -1,4 +1,5 @@
>  obj-$(CONFIG_PHY_CYGNUS_PCIE)  += phy-bcm-cygnus-pcie.o
> +obj-$(CONFIG_PHY_BCM_CYGNUS_USB)   += phy-bcm-cygnus-usb.o
>  obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
>  obj-$(CONFIG_PHY_BCM_NS_USB2)  += phy-bcm-ns-usb2.o
>  obj-$(CONFIG_PHY_BCM_NS_USB3)  += phy-bcm-ns-usb3.o
> diff --git a/drivers/phy/broadcom/phy-bcm-cygnus-usb.c 
> b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
> new file mode 100644
> index 000..cf957d4
> --- /dev/null
> +++ b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
> @@ -0,0 +1,690 @@
> +/*
> + * Copyright 2017 Broadcom
> + *
> + * 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 (the "GPL").
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License version 2 (GPLv2) for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * version 2 (GPLv2) along with this source code.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* CDRU Block Register Offsets and bit definitions */
> +#define CDRU_USBPHY_CLK_RST_SEL_OFFSET 0x0
> +#define CDRU_USBPHY2_HOST_DEV_SEL_OFFSET   0x4
> +#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_OFFSET0x5C
> +#define CDRU_USBPHY_P0_STATUS_OFFSET   0x1C
> +#define CDRU_USBPHY_P1_STATUS_OFFSET   0x34
> +#define CDRU_USBPHY_P2_STATUS_OFFSET   0x4C
> +
> +#define CDRU_USBPHY_USBPHY_ILDO_ON_FLAGBIT(1)
> +#define CDRU_USBPHY_USBPHY_PLL_LOCKBIT(0)
> +#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_DISABLE   BIT(0)
> +
> +/* CRMU Block Register Offsets and bit definitions */
> +#define CRMU_USB_PHY_AON_CTRL_OFFSET   0x0
> +#define CRMU_USBPHY_P0_AFE_CORERDY_VDDCBIT(1)
> +#define CRMU_USBPHY_P0_RESETB  BIT(2)
> +#define CRMU_USBPHY_P1_AFE_CORERDY_VDDCBIT(9)
> +#define CRMU_USBPHY_P1_RESETB  BIT(10)
> +#define CRMU_USBPHY_P2_AFE_CORERDY_VDDCBIT(17)
> +#define CRMU_USBPHY_P2_RESETB  BIT(18)
> +
> +/* U

[PATCH v2 0/3] Add driver for Broadcom Cygnus USB phy controller

2017-11-07 Thread Raveendra Padasalagi
Add driver for Broadcom's USB phy controller's used in Cygnus family
of SoC and it's based on 4.14-rc3 tag.

The patch set can be fetched from iproc-cyg-usb-v2 branch of
https://github.com/Broadcom/arm64-linux.git

Changes since v1:
  - Added "dt-bindings: phy:" subject prefix in dt bindings patch
  - Renamed phy node name from "phy" to "usb-phy"
  - Added BIT() macro definitions for some of the register bit access
  - Added .owner in phy_ops structure.
  - Added cygnus_phy_shutdown_all() to keep probe() clean.
  - Used devm_extcon_register_notifier() instead of extcon_register_notifier()

Raveendra Padasalagi (3):
  dt-bindings: phy: Add Cygnus usb phy binding
  drivers: phy: broadcom: Add driver for Cygnus USB phy controller
  ARM: dts: Add dt node for Broadcom Cygnus USB phy

 .../bindings/phy/brcm,cygnus-usb-phy.txt   | 106 
 arch/arm/boot/dts/bcm-cygnus.dtsi  |  35 ++
 drivers/phy/broadcom/Kconfig   |  14 +
 drivers/phy/broadcom/Makefile  |   1 +
 drivers/phy/broadcom/phy-bcm-cygnus-usb.c  | 690 +
 5 files changed, 846 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
 create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c

-- 
1.9.1



[PATCH v2 1/3] dt-bindings: phy: Add Cygnus usb phy binding

2017-11-07 Thread Raveendra Padasalagi
Add devicetree binding document for broadcom's
Cygnus SoC specific usb phy controller driver.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
---
 .../bindings/phy/brcm,cygnus-usb-phy.txt   | 106 +
 1 file changed, 106 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt 
b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
new file mode 100644
index 000..bbc4b94
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
@@ -0,0 +1,106 @@
+BROADCOM CYGNUS USB PHY
+
+Required Properties:
+- compatible:  brcm,cygnus-usb-phy
+- reg : the register start address and length for
+crmu_usbphy_aon_ctrl,
+cdru usb phy control,
+usb host idm registers,
+usb device idm registers.
+- reg-names: a list of the names corresponding to the previous register ranges
+  Should contain
+"crmu-usbphy-aon-ctrl",
+"cdru-usbphy",
+"usb2h-idm",
+"usb2d-idm".
+- address-cells: should be 1
+- size-cells: should be 0
+
+Sub-nodes:
+  Each port's PHY should be represented as a sub-node.
+
+Sub-nodes required properties:
+- reg: the PHY number
+- #phy-cells must be 1
+  The node that uses the phy must provide 1 integer argument specifying
+  port number.
+
+Optional Properties:
+- vbus-p#-supply : The regulator for vbus out control for the host
+  functionality enabled ports.
+- vbus-gpios: vbus gpio binding
+  This is mandatory for port 2, as port 2 is used as dual role phy.
+  Based on the vbus and id values device or host role is determined
+  for phy 2.
+
+- extcon: extcon phandle
+  This is mandatory for port 2,  as port 2 is used as dual role phy.
+  extcon should be phandle to external usb gpio module which provide
+  device or host role notifications based on the ID and VBUS gpio's state.
+
+
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+NOTE: port 0 and port 1 are host only and port 2 is dual role port.
+
+Example of phy :
+   usbphy: usb-phy@0301c028 {
+   compatible = "brcm,cygnus-usb-phy";
+   reg = <0x0301c028 0x4>,
+ <0x0301d1b4 0x5c>,
+ <0x18115000 0xa00>,
+ <0x18111000 0xa00>;
+   reg-names = "crmu-usbphy-aon-ctrl", "cdru-usbphy",
+   "usb2h-idm", "usb2d-idm";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   usbphy0: usb-phy@0 {
+   reg = <0>;
+   #phy-cells = <1>;
+   };
+
+   usbphy1: usb-phy@1 {
+   reg = <1>;
+   #phy-cells = <1>;
+   };
+
+   usbphy2: usb-phy@2 {
+   reg = <2>;
+   #phy-cells = <1>;
+   extcon = <_usb>;
+   };
+   };
+
+   extcon_usb: extcon_usb {
+   compatible = "linux,extcon-usb-gpio";
+   vbus-gpio = <_asiu 121 0>;
+   id-gpio = <_asiu 122 0>;
+   status = "okay";
+   };
+
+
+Example of node using the phy:
+
+   /* This nodes declares all three ports, port 0
+   and port 1 are host and port 2 is device or host */
+
+   ehci0: usb@18048000 {
+   compatible = "generic-ehci";
+   reg = <0x18048000 0x100>;
+   interrupts = ;
+   phys = < 0  1  2>;
+   phy-names = "usbp0","usbp1","usbp2";
+   status = "okay";
+   };
+
+   /* This node declares port 2 phy
+   and configures it for device */
+
+   usbd_udc_dwc1: usb@1804c000 {
+   compatible = "iproc-udc";
+   reg = <0x1804c000 0x2000>;
+   interrupts = ;
+   phys = < 2>;
+   phy-names = "usbdrd";
+   };
-- 
1.9.1



[PATCH v2 0/3] Add driver for Broadcom Cygnus USB phy controller

2017-11-07 Thread Raveendra Padasalagi
Add driver for Broadcom's USB phy controller's used in Cygnus family
of SoC and it's based on 4.14-rc3 tag.

The patch set can be fetched from iproc-cyg-usb-v2 branch of
https://github.com/Broadcom/arm64-linux.git

Changes since v1:
  - Added "dt-bindings: phy:" subject prefix in dt bindings patch
  - Renamed phy node name from "phy" to "usb-phy"
  - Added BIT() macro definitions for some of the register bit access
  - Added .owner in phy_ops structure.
  - Added cygnus_phy_shutdown_all() to keep probe() clean.
  - Used devm_extcon_register_notifier() instead of extcon_register_notifier()

Raveendra Padasalagi (3):
  dt-bindings: phy: Add Cygnus usb phy binding
  drivers: phy: broadcom: Add driver for Cygnus USB phy controller
  ARM: dts: Add dt node for Broadcom Cygnus USB phy

 .../bindings/phy/brcm,cygnus-usb-phy.txt   | 106 
 arch/arm/boot/dts/bcm-cygnus.dtsi  |  35 ++
 drivers/phy/broadcom/Kconfig   |  14 +
 drivers/phy/broadcom/Makefile  |   1 +
 drivers/phy/broadcom/phy-bcm-cygnus-usb.c  | 690 +
 5 files changed, 846 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
 create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c

-- 
1.9.1



[PATCH v2 1/3] dt-bindings: phy: Add Cygnus usb phy binding

2017-11-07 Thread Raveendra Padasalagi
Add devicetree binding document for broadcom's
Cygnus SoC specific usb phy controller driver.

Signed-off-by: Raveendra Padasalagi 
---
 .../bindings/phy/brcm,cygnus-usb-phy.txt   | 106 +
 1 file changed, 106 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt 
b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
new file mode 100644
index 000..bbc4b94
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
@@ -0,0 +1,106 @@
+BROADCOM CYGNUS USB PHY
+
+Required Properties:
+- compatible:  brcm,cygnus-usb-phy
+- reg : the register start address and length for
+crmu_usbphy_aon_ctrl,
+cdru usb phy control,
+usb host idm registers,
+usb device idm registers.
+- reg-names: a list of the names corresponding to the previous register ranges
+  Should contain
+"crmu-usbphy-aon-ctrl",
+"cdru-usbphy",
+"usb2h-idm",
+"usb2d-idm".
+- address-cells: should be 1
+- size-cells: should be 0
+
+Sub-nodes:
+  Each port's PHY should be represented as a sub-node.
+
+Sub-nodes required properties:
+- reg: the PHY number
+- #phy-cells must be 1
+  The node that uses the phy must provide 1 integer argument specifying
+  port number.
+
+Optional Properties:
+- vbus-p#-supply : The regulator for vbus out control for the host
+  functionality enabled ports.
+- vbus-gpios: vbus gpio binding
+  This is mandatory for port 2, as port 2 is used as dual role phy.
+  Based on the vbus and id values device or host role is determined
+  for phy 2.
+
+- extcon: extcon phandle
+  This is mandatory for port 2,  as port 2 is used as dual role phy.
+  extcon should be phandle to external usb gpio module which provide
+  device or host role notifications based on the ID and VBUS gpio's state.
+
+
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+NOTE: port 0 and port 1 are host only and port 2 is dual role port.
+
+Example of phy :
+   usbphy: usb-phy@0301c028 {
+   compatible = "brcm,cygnus-usb-phy";
+   reg = <0x0301c028 0x4>,
+ <0x0301d1b4 0x5c>,
+ <0x18115000 0xa00>,
+ <0x18111000 0xa00>;
+   reg-names = "crmu-usbphy-aon-ctrl", "cdru-usbphy",
+   "usb2h-idm", "usb2d-idm";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   usbphy0: usb-phy@0 {
+   reg = <0>;
+   #phy-cells = <1>;
+   };
+
+   usbphy1: usb-phy@1 {
+   reg = <1>;
+   #phy-cells = <1>;
+   };
+
+   usbphy2: usb-phy@2 {
+   reg = <2>;
+   #phy-cells = <1>;
+   extcon = <_usb>;
+   };
+   };
+
+   extcon_usb: extcon_usb {
+   compatible = "linux,extcon-usb-gpio";
+   vbus-gpio = <_asiu 121 0>;
+   id-gpio = <_asiu 122 0>;
+   status = "okay";
+   };
+
+
+Example of node using the phy:
+
+   /* This nodes declares all three ports, port 0
+   and port 1 are host and port 2 is device or host */
+
+   ehci0: usb@18048000 {
+   compatible = "generic-ehci";
+   reg = <0x18048000 0x100>;
+   interrupts = ;
+   phys = < 0  1  2>;
+   phy-names = "usbp0","usbp1","usbp2";
+   status = "okay";
+   };
+
+   /* This node declares port 2 phy
+   and configures it for device */
+
+   usbd_udc_dwc1: usb@1804c000 {
+   compatible = "iproc-udc";
+   reg = <0x1804c000 0x2000>;
+   interrupts = ;
+   phys = < 2>;
+   phy-names = "usbdrd";
+   };
-- 
1.9.1



[PATCH v2 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-11-07 Thread Raveendra Padasalagi
Add driver for Broadcom's USB phy controller's used in Cygnus
familyof SoC. Cygnus has three USB phy controller's, port 0,
port 1 provides USB host functionality and port 2 can be configured
for host/device role.

Configuration of host/device role for port 2 is achieved based on
the extcon events, the driver registers to extcon framework to get
appropriate connect events for Host/Device cables connect/disconnect
states based on VBUS and ID interrupts.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
---
 drivers/phy/broadcom/Kconfig  |  14 +
 drivers/phy/broadcom/Makefile |   1 +
 drivers/phy/broadcom/phy-bcm-cygnus-usb.c | 690 ++
 3 files changed, 705 insertions(+)
 create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c

diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
index 64fc59c..3179daf 100644
--- a/drivers/phy/broadcom/Kconfig
+++ b/drivers/phy/broadcom/Kconfig
@@ -1,6 +1,20 @@
 #
 # Phy drivers for Broadcom platforms
 #
+config PHY_BCM_CYGNUS_USB
+   tristate "Broadcom Cygnus USB PHY support"
+   depends on OF
+   depends on ARCH_BCM_CYGNUS || COMPILE_TEST
+   select GENERIC_PHY
+   select EXTCON_USB_GPIO
+   default ARCH_BCM_CYGNUS
+   help
+ Enable this to support three USB PHY's present in Broadcom's
+ Cygnus chip.
+
+ The phys are capable of supporting host mode on all ports and
+ device mode for port 2.
+
 config PHY_CYGNUS_PCIE
tristate "Broadcom Cygnus PCIe PHY driver"
depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
index 4eb82ec..3dec23c 100644
--- a/drivers/phy/broadcom/Makefile
+++ b/drivers/phy/broadcom/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_PHY_CYGNUS_PCIE)  += phy-bcm-cygnus-pcie.o
+obj-$(CONFIG_PHY_BCM_CYGNUS_USB)   += phy-bcm-cygnus-usb.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB2)  += phy-bcm-ns-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB3)  += phy-bcm-ns-usb3.o
diff --git a/drivers/phy/broadcom/phy-bcm-cygnus-usb.c 
b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
new file mode 100644
index 000..cf957d4
--- /dev/null
+++ b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
@@ -0,0 +1,690 @@
+/*
+ * Copyright 2017 Broadcom
+ *
+ * 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 (the "GPL").
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 (GPLv2) for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 (GPLv2) along with this source code.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* CDRU Block Register Offsets and bit definitions */
+#define CDRU_USBPHY_CLK_RST_SEL_OFFSET 0x0
+#define CDRU_USBPHY2_HOST_DEV_SEL_OFFSET   0x4
+#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_OFFSET0x5C
+#define CDRU_USBPHY_P0_STATUS_OFFSET   0x1C
+#define CDRU_USBPHY_P1_STATUS_OFFSET   0x34
+#define CDRU_USBPHY_P2_STATUS_OFFSET   0x4C
+
+#define CDRU_USBPHY_USBPHY_ILDO_ON_FLAGBIT(1)
+#define CDRU_USBPHY_USBPHY_PLL_LOCKBIT(0)
+#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_DISABLE   BIT(0)
+
+/* CRMU Block Register Offsets and bit definitions */
+#define CRMU_USB_PHY_AON_CTRL_OFFSET   0x0
+#define CRMU_USBPHY_P0_AFE_CORERDY_VDDCBIT(1)
+#define CRMU_USBPHY_P0_RESETB  BIT(2)
+#define CRMU_USBPHY_P1_AFE_CORERDY_VDDCBIT(9)
+#define CRMU_USBPHY_P1_RESETB  BIT(10)
+#define CRMU_USBPHY_P2_AFE_CORERDY_VDDCBIT(17)
+#define CRMU_USBPHY_P2_RESETB  BIT(18)
+
+/* USB2 IDM Block register Offset and bit definitions */
+#define USB2_IDM_IDM_IO_CONTROL_DIRECT_OFFSET  0x0408
+#define USB2_IDM_IDM_IO_CONTROL_DIRECT_CLK_ENABLE  BIT(0)
+#define SUSPEND_OVERRIDE_0 BIT(13)
+#define SUSPEND_OVERRIDE_0_POS 13
+#define SUSPEND_OVERRIDE_1 BIT(14)
+#define SUSPEND_OVERRIDE_1_POS 14
+#define SUSPEND_OVERRIDE_2 BIT(15)
+#define SUSPEND_OVERRIDE_2_POS 15
+
+#define USB2_IDM_IDM_RESET_CONTROL_OFFSET  0x0800
+#define USB2_IDM_IDM_RESET

[PATCH v2 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-11-07 Thread Raveendra Padasalagi
Add driver for Broadcom's USB phy controller's used in Cygnus
familyof SoC. Cygnus has three USB phy controller's, port 0,
port 1 provides USB host functionality and port 2 can be configured
for host/device role.

Configuration of host/device role for port 2 is achieved based on
the extcon events, the driver registers to extcon framework to get
appropriate connect events for Host/Device cables connect/disconnect
states based on VBUS and ID interrupts.

Signed-off-by: Raveendra Padasalagi 
---
 drivers/phy/broadcom/Kconfig  |  14 +
 drivers/phy/broadcom/Makefile |   1 +
 drivers/phy/broadcom/phy-bcm-cygnus-usb.c | 690 ++
 3 files changed, 705 insertions(+)
 create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c

diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
index 64fc59c..3179daf 100644
--- a/drivers/phy/broadcom/Kconfig
+++ b/drivers/phy/broadcom/Kconfig
@@ -1,6 +1,20 @@
 #
 # Phy drivers for Broadcom platforms
 #
+config PHY_BCM_CYGNUS_USB
+   tristate "Broadcom Cygnus USB PHY support"
+   depends on OF
+   depends on ARCH_BCM_CYGNUS || COMPILE_TEST
+   select GENERIC_PHY
+   select EXTCON_USB_GPIO
+   default ARCH_BCM_CYGNUS
+   help
+ Enable this to support three USB PHY's present in Broadcom's
+ Cygnus chip.
+
+ The phys are capable of supporting host mode on all ports and
+ device mode for port 2.
+
 config PHY_CYGNUS_PCIE
tristate "Broadcom Cygnus PCIe PHY driver"
depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
index 4eb82ec..3dec23c 100644
--- a/drivers/phy/broadcom/Makefile
+++ b/drivers/phy/broadcom/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_PHY_CYGNUS_PCIE)  += phy-bcm-cygnus-pcie.o
+obj-$(CONFIG_PHY_BCM_CYGNUS_USB)   += phy-bcm-cygnus-usb.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB2)  += phy-bcm-ns-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB3)  += phy-bcm-ns-usb3.o
diff --git a/drivers/phy/broadcom/phy-bcm-cygnus-usb.c 
b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
new file mode 100644
index 000..cf957d4
--- /dev/null
+++ b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
@@ -0,0 +1,690 @@
+/*
+ * Copyright 2017 Broadcom
+ *
+ * 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 (the "GPL").
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 (GPLv2) for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 (GPLv2) along with this source code.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* CDRU Block Register Offsets and bit definitions */
+#define CDRU_USBPHY_CLK_RST_SEL_OFFSET 0x0
+#define CDRU_USBPHY2_HOST_DEV_SEL_OFFSET   0x4
+#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_OFFSET0x5C
+#define CDRU_USBPHY_P0_STATUS_OFFSET   0x1C
+#define CDRU_USBPHY_P1_STATUS_OFFSET   0x34
+#define CDRU_USBPHY_P2_STATUS_OFFSET   0x4C
+
+#define CDRU_USBPHY_USBPHY_ILDO_ON_FLAGBIT(1)
+#define CDRU_USBPHY_USBPHY_PLL_LOCKBIT(0)
+#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_DISABLE   BIT(0)
+
+/* CRMU Block Register Offsets and bit definitions */
+#define CRMU_USB_PHY_AON_CTRL_OFFSET   0x0
+#define CRMU_USBPHY_P0_AFE_CORERDY_VDDCBIT(1)
+#define CRMU_USBPHY_P0_RESETB  BIT(2)
+#define CRMU_USBPHY_P1_AFE_CORERDY_VDDCBIT(9)
+#define CRMU_USBPHY_P1_RESETB  BIT(10)
+#define CRMU_USBPHY_P2_AFE_CORERDY_VDDCBIT(17)
+#define CRMU_USBPHY_P2_RESETB  BIT(18)
+
+/* USB2 IDM Block register Offset and bit definitions */
+#define USB2_IDM_IDM_IO_CONTROL_DIRECT_OFFSET  0x0408
+#define USB2_IDM_IDM_IO_CONTROL_DIRECT_CLK_ENABLE  BIT(0)
+#define SUSPEND_OVERRIDE_0 BIT(13)
+#define SUSPEND_OVERRIDE_0_POS 13
+#define SUSPEND_OVERRIDE_1 BIT(14)
+#define SUSPEND_OVERRIDE_1_POS 14
+#define SUSPEND_OVERRIDE_2 BIT(15)
+#define SUSPEND_OVERRIDE_2_POS 15
+
+#define USB2_IDM_IDM_RESET_CONTROL_OFFSET  0x0800
+#define USB2_IDM_IDM_RESET_CONTR

[PATCH v2 3/3] ARM: dts: Add dt node for Broadcom Cygnus USB phy

2017-11-07 Thread Raveendra Padasalagi
Add DT node for Broadcom's USB phy controller's used
in Cygnus family of SoC.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
---
 arch/arm/boot/dts/bcm-cygnus.dtsi | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi 
b/arch/arm/boot/dts/bcm-cygnus.dtsi
index 7c957ea..c7b39dd 100644
--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
+++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
@@ -96,6 +96,41 @@
#address-cells = <1>;
#size-cells = <1>;
 
+   extcon_usb: extcon_usb {
+   compatible = "linux,extcon-usb-gpio";
+   vbus-gpio = <_asiu 121 0>;
+   id-gpio = <_asiu 122 0>;
+   status = "okay";
+   };
+
+   usbphy: usb-phy@0301c028 {
+   compatible = "brcm,cygnus-usb-phy";
+   reg = <0x0301c028 0x4>,
+ <0x0301d1b4 0x5c>,
+ <0x18115000 0xa00>,
+ <0x18111000 0xa00>;
+   reg-names = "crmu-usbphy-aon-ctrl", "cdru-usbphy",
+   "usb2h-idm", "usb2d-idm";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   usbphy0: usb-phy@0 {
+   #phy-cells = <1>;
+   reg = <0>;
+   };
+
+   usbphy1: usb-phy@1 {
+   #phy-cells = <1>;
+   reg = <1>;
+   };
+
+   usbphy2: usb-phy@2 {
+   #phy-cells = <1>;
+   reg = <2>;
+   extcon = <_usb>;
+   };
+   };
+
otp: otp@0301c800 {
compatible = "brcm,ocotp";
reg = <0x0301c800 0x2c>;
-- 
1.9.1



[PATCH v2 3/3] ARM: dts: Add dt node for Broadcom Cygnus USB phy

2017-11-07 Thread Raveendra Padasalagi
Add DT node for Broadcom's USB phy controller's used
in Cygnus family of SoC.

Signed-off-by: Raveendra Padasalagi 
---
 arch/arm/boot/dts/bcm-cygnus.dtsi | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi 
b/arch/arm/boot/dts/bcm-cygnus.dtsi
index 7c957ea..c7b39dd 100644
--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
+++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
@@ -96,6 +96,41 @@
#address-cells = <1>;
#size-cells = <1>;
 
+   extcon_usb: extcon_usb {
+   compatible = "linux,extcon-usb-gpio";
+   vbus-gpio = <_asiu 121 0>;
+   id-gpio = <_asiu 122 0>;
+   status = "okay";
+   };
+
+   usbphy: usb-phy@0301c028 {
+   compatible = "brcm,cygnus-usb-phy";
+   reg = <0x0301c028 0x4>,
+ <0x0301d1b4 0x5c>,
+ <0x18115000 0xa00>,
+ <0x18111000 0xa00>;
+   reg-names = "crmu-usbphy-aon-ctrl", "cdru-usbphy",
+   "usb2h-idm", "usb2d-idm";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   usbphy0: usb-phy@0 {
+   #phy-cells = <1>;
+   reg = <0>;
+   };
+
+   usbphy1: usb-phy@1 {
+   #phy-cells = <1>;
+   reg = <1>;
+   };
+
+   usbphy2: usb-phy@2 {
+   #phy-cells = <1>;
+   reg = <2>;
+   extcon = <_usb>;
+   };
+   };
+
otp: otp@0301c800 {
compatible = "brcm,ocotp";
reg = <0x0301c800 0x2c>;
-- 
1.9.1



Re: [PATCH 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-10-29 Thread Raveendra Padasalagi
Hi Chanwoo,

On Mon, Oct 30, 2017 at 5:32 AM, Chanwoo Choi <cw00.c...@samsung.com> wrote:
> Hi,
>
> On 2017년 10월 27일 17:35, Kishon Vijay Abraham I wrote:
>> +Chanwoo, for reviewing extcon
>>
>> Hi.
>>
>> On Tuesday 24 October 2017 10:07 AM, Raveendra Padasalagi wrote:
>>> Add driver for Broadcom's USB phy controller's used in Cygnus
>>> familyof SoC. Cygnus has three USB phy controller's, port 0,
>>> port 1 provides USB host functionality and port 2 can be configured
>>> for host/device role.
>>>
>>> Configuration of host/device role for port 2 is achieved based on
>>> the extcon events, the driver registers to extcon framework to get
>>> appropriate connect events for Host/Device cables connect/disconnect
>>> states based on VBUS and ID interrupts.
>>>
>>> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
>>> ---
>>>  drivers/phy/broadcom/Kconfig  |  14 +
>>>  drivers/phy/broadcom/Makefile |   1 +
>>>  drivers/phy/broadcom/phy-bcm-cygnus-usb.c | 672 
>>> ++
>>>  3 files changed, 687 insertions(+)
>>>  create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>>
>>> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
>>> index 64fc59c..3179daf 100644
>>> --- a/drivers/phy/broadcom/Kconfig
>>> +++ b/drivers/phy/broadcom/Kconfig
>>> @@ -1,6 +1,20 @@
>>>  #
>>>  # Phy drivers for Broadcom platforms
>>>  #
>>> +config PHY_BCM_CYGNUS_USB
>>> +tristate "Broadcom Cygnus USB PHY support"
>>> +depends on OF
>>> +depends on ARCH_BCM_CYGNUS || COMPILE_TEST
>>> +select GENERIC_PHY
>>> +select EXTCON_USB_GPIO
>
> IMO, it is not good to add the dependency to the specific device driver.
> Instead, you better to depend on the EXTCON framework (select EXTCON)
> such as 'select GENERIC_PHY'.

GENERIC_PHY dependency is anyway needed and it's added as dependency.
Let me add "depends on EXTCON" instead of "select EXTCON"

>>
>> Didn't this throw up a warning for selecting config without caring for the
>> dependency?
>>
>>> +default ARCH_BCM_CYGNUS
>>> +help
>>> +  Enable this to support three USB PHY's present in Broadcom's
>>> +  Cygnus chip.
>>> +
>>> +  The phys are capable of supporting host mode on all ports and
>>> +  device mode for port 2.
>>> +
>>>  config PHY_CYGNUS_PCIE
>>>  tristate "Broadcom Cygnus PCIe PHY driver"
>>>  depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
>>> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
>>> index 4eb82ec..3dec23c 100644
>>> --- a/drivers/phy/broadcom/Makefile
>>> +++ b/drivers/phy/broadcom/Makefile
>>> @@ -1,4 +1,5 @@
>>>  obj-$(CONFIG_PHY_CYGNUS_PCIE)   += phy-bcm-cygnus-pcie.o
>>> +obj-$(CONFIG_PHY_BCM_CYGNUS_USB)+= phy-bcm-cygnus-usb.o
>>>  obj-$(CONFIG_BCM_KONA_USB2_PHY) += phy-bcm-kona-usb2.o
>>>  obj-$(CONFIG_PHY_BCM_NS_USB2)   += phy-bcm-ns-usb2.o
>>>  obj-$(CONFIG_PHY_BCM_NS_USB3)   += phy-bcm-ns-usb3.o
>>> diff --git a/drivers/phy/broadcom/phy-bcm-cygnus-usb.c 
>>> b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>> new file mode 100644
>>> index 000..ef2a94c
>>> --- /dev/null
>>> +++ b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>> @@ -0,0 +1,672 @@
>>> +/*
>>> + * Copyright 2017 Broadcom
>>> + *
>>> + * 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 (the "GPL").
>>> + *
>>> + * This program is distributed in the hope that it will be useful, but
>>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>>> + * General Public License version 2 (GPLv2) for more details.
>>> + *
>>> + * You should have received a copy of the GNU General Public License
>>> + * version 2 (GPLv2) along with this source code.
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 

Re: [PATCH 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-10-29 Thread Raveendra Padasalagi
Hi Chanwoo,

On Mon, Oct 30, 2017 at 5:32 AM, Chanwoo Choi  wrote:
> Hi,
>
> On 2017년 10월 27일 17:35, Kishon Vijay Abraham I wrote:
>> +Chanwoo, for reviewing extcon
>>
>> Hi.
>>
>> On Tuesday 24 October 2017 10:07 AM, Raveendra Padasalagi wrote:
>>> Add driver for Broadcom's USB phy controller's used in Cygnus
>>> familyof SoC. Cygnus has three USB phy controller's, port 0,
>>> port 1 provides USB host functionality and port 2 can be configured
>>> for host/device role.
>>>
>>> Configuration of host/device role for port 2 is achieved based on
>>> the extcon events, the driver registers to extcon framework to get
>>> appropriate connect events for Host/Device cables connect/disconnect
>>> states based on VBUS and ID interrupts.
>>>
>>> Signed-off-by: Raveendra Padasalagi 
>>> ---
>>>  drivers/phy/broadcom/Kconfig  |  14 +
>>>  drivers/phy/broadcom/Makefile |   1 +
>>>  drivers/phy/broadcom/phy-bcm-cygnus-usb.c | 672 
>>> ++
>>>  3 files changed, 687 insertions(+)
>>>  create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>>
>>> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
>>> index 64fc59c..3179daf 100644
>>> --- a/drivers/phy/broadcom/Kconfig
>>> +++ b/drivers/phy/broadcom/Kconfig
>>> @@ -1,6 +1,20 @@
>>>  #
>>>  # Phy drivers for Broadcom platforms
>>>  #
>>> +config PHY_BCM_CYGNUS_USB
>>> +tristate "Broadcom Cygnus USB PHY support"
>>> +depends on OF
>>> +depends on ARCH_BCM_CYGNUS || COMPILE_TEST
>>> +select GENERIC_PHY
>>> +select EXTCON_USB_GPIO
>
> IMO, it is not good to add the dependency to the specific device driver.
> Instead, you better to depend on the EXTCON framework (select EXTCON)
> such as 'select GENERIC_PHY'.

GENERIC_PHY dependency is anyway needed and it's added as dependency.
Let me add "depends on EXTCON" instead of "select EXTCON"

>>
>> Didn't this throw up a warning for selecting config without caring for the
>> dependency?
>>
>>> +default ARCH_BCM_CYGNUS
>>> +help
>>> +  Enable this to support three USB PHY's present in Broadcom's
>>> +  Cygnus chip.
>>> +
>>> +  The phys are capable of supporting host mode on all ports and
>>> +  device mode for port 2.
>>> +
>>>  config PHY_CYGNUS_PCIE
>>>  tristate "Broadcom Cygnus PCIe PHY driver"
>>>  depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
>>> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
>>> index 4eb82ec..3dec23c 100644
>>> --- a/drivers/phy/broadcom/Makefile
>>> +++ b/drivers/phy/broadcom/Makefile
>>> @@ -1,4 +1,5 @@
>>>  obj-$(CONFIG_PHY_CYGNUS_PCIE)   += phy-bcm-cygnus-pcie.o
>>> +obj-$(CONFIG_PHY_BCM_CYGNUS_USB)+= phy-bcm-cygnus-usb.o
>>>  obj-$(CONFIG_BCM_KONA_USB2_PHY) += phy-bcm-kona-usb2.o
>>>  obj-$(CONFIG_PHY_BCM_NS_USB2)   += phy-bcm-ns-usb2.o
>>>  obj-$(CONFIG_PHY_BCM_NS_USB3)   += phy-bcm-ns-usb3.o
>>> diff --git a/drivers/phy/broadcom/phy-bcm-cygnus-usb.c 
>>> b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>> new file mode 100644
>>> index 000..ef2a94c
>>> --- /dev/null
>>> +++ b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>> @@ -0,0 +1,672 @@
>>> +/*
>>> + * Copyright 2017 Broadcom
>>> + *
>>> + * 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 (the "GPL").
>>> + *
>>> + * This program is distributed in the hope that it will be useful, but
>>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>>> + * General Public License version 2 (GPLv2) for more details.
>>> + *
>>> + * You should have received a copy of the GNU General Public License
>>> + * version 2 (GPLv2) along with this source code.
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>&g

Re: [PATCH 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-10-29 Thread Raveendra Padasalagi
Hi Kishon,

On Fri, Oct 27, 2017 at 2:05 PM, Kishon Vijay Abraham I <kis...@ti.com> wrote:
> +Chanwoo, for reviewing extcon
>
> Hi.
>
> On Tuesday 24 October 2017 10:07 AM, Raveendra Padasalagi wrote:
>> Add driver for Broadcom's USB phy controller's used in Cygnus
>> familyof SoC. Cygnus has three USB phy controller's, port 0,
>> port 1 provides USB host functionality and port 2 can be configured
>> for host/device role.
>>
>> Configuration of host/device role for port 2 is achieved based on
>> the extcon events, the driver registers to extcon framework to get
>> appropriate connect events for Host/Device cables connect/disconnect
>> states based on VBUS and ID interrupts.
>>
>> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
>> ---
>>  drivers/phy/broadcom/Kconfig  |  14 +
>>  drivers/phy/broadcom/Makefile |   1 +
>>  drivers/phy/broadcom/phy-bcm-cygnus-usb.c | 672 
>> ++
>>  3 files changed, 687 insertions(+)
>>  create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>
>> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
>> index 64fc59c..3179daf 100644
>> --- a/drivers/phy/broadcom/Kconfig
>> +++ b/drivers/phy/broadcom/Kconfig
>> @@ -1,6 +1,20 @@
>>  #
>>  # Phy drivers for Broadcom platforms
>>  #
>> +config PHY_BCM_CYGNUS_USB
>> + tristate "Broadcom Cygnus USB PHY support"
>> + depends on OF
>> + depends on ARCH_BCM_CYGNUS || COMPILE_TEST
>> + select GENERIC_PHY
>> + select EXTCON_USB_GPIO
>
> Didn't this throw up a warning for selecting config without caring for the
> dependency?

No, it didn't throw any warning. Let me remove select and place it as
dependency.

>> + default ARCH_BCM_CYGNUS
>> + help
>> +   Enable this to support three USB PHY's present in Broadcom's
>> +   Cygnus chip.
>> +
>> +   The phys are capable of supporting host mode on all ports and
>> +   device mode for port 2.
>> +
>>  config PHY_CYGNUS_PCIE
>>   tristate "Broadcom Cygnus PCIe PHY driver"
>>   depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
>> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
>> index 4eb82ec..3dec23c 100644
>> --- a/drivers/phy/broadcom/Makefile
>> +++ b/drivers/phy/broadcom/Makefile
>> @@ -1,4 +1,5 @@
>>  obj-$(CONFIG_PHY_CYGNUS_PCIE)+= phy-bcm-cygnus-pcie.o
>> +obj-$(CONFIG_PHY_BCM_CYGNUS_USB) += phy-bcm-cygnus-usb.o
>>  obj-$(CONFIG_BCM_KONA_USB2_PHY)  += phy-bcm-kona-usb2.o
>>  obj-$(CONFIG_PHY_BCM_NS_USB2)+= phy-bcm-ns-usb2.o
>>  obj-$(CONFIG_PHY_BCM_NS_USB3)+= phy-bcm-ns-usb3.o
>> diff --git a/drivers/phy/broadcom/phy-bcm-cygnus-usb.c 
>> b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>> new file mode 100644
>> index 000..ef2a94c
>> --- /dev/null
>> +++ b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>> @@ -0,0 +1,672 @@
>> +/*
>> + * Copyright 2017 Broadcom
>> + *
>> + * 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 (the "GPL").
>> + *
>> + * This program is distributed in the hope that it will be useful, but
>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * General Public License version 2 (GPLv2) for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * version 2 (GPLv2) along with this source code.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define CDRU_USBPHY_CLK_RST_SEL_OFFSET   0x0
>> +#define CDRU_USBPHY2_HOST_DEV_SEL_OFFSET 0x4
>> +#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_OFFSET  0x5C
>> +#define CDRU_USBPHY_P0_STATUS_OFFSET 0x1C
>> +#define CDRU_USBPHY_P1_STATUS_OFFSET 0x34
>> +#define CDRU_USBPHY_P2_STATUS_OFFSET 0x4C
>
> Looks like it has 2 different blocks; CDRU and CMRU. Having a comment for each
> of the block will help.

Ok, I will fix it in the next version

Re: [PATCH 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-10-29 Thread Raveendra Padasalagi
Hi Kishon,

On Fri, Oct 27, 2017 at 2:05 PM, Kishon Vijay Abraham I  wrote:
> +Chanwoo, for reviewing extcon
>
> Hi.
>
> On Tuesday 24 October 2017 10:07 AM, Raveendra Padasalagi wrote:
>> Add driver for Broadcom's USB phy controller's used in Cygnus
>> familyof SoC. Cygnus has three USB phy controller's, port 0,
>> port 1 provides USB host functionality and port 2 can be configured
>> for host/device role.
>>
>> Configuration of host/device role for port 2 is achieved based on
>> the extcon events, the driver registers to extcon framework to get
>> appropriate connect events for Host/Device cables connect/disconnect
>> states based on VBUS and ID interrupts.
>>
>> Signed-off-by: Raveendra Padasalagi 
>> ---
>>  drivers/phy/broadcom/Kconfig  |  14 +
>>  drivers/phy/broadcom/Makefile |   1 +
>>  drivers/phy/broadcom/phy-bcm-cygnus-usb.c | 672 
>> ++
>>  3 files changed, 687 insertions(+)
>>  create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>>
>> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
>> index 64fc59c..3179daf 100644
>> --- a/drivers/phy/broadcom/Kconfig
>> +++ b/drivers/phy/broadcom/Kconfig
>> @@ -1,6 +1,20 @@
>>  #
>>  # Phy drivers for Broadcom platforms
>>  #
>> +config PHY_BCM_CYGNUS_USB
>> + tristate "Broadcom Cygnus USB PHY support"
>> + depends on OF
>> + depends on ARCH_BCM_CYGNUS || COMPILE_TEST
>> + select GENERIC_PHY
>> + select EXTCON_USB_GPIO
>
> Didn't this throw up a warning for selecting config without caring for the
> dependency?

No, it didn't throw any warning. Let me remove select and place it as
dependency.

>> + default ARCH_BCM_CYGNUS
>> + help
>> +   Enable this to support three USB PHY's present in Broadcom's
>> +   Cygnus chip.
>> +
>> +   The phys are capable of supporting host mode on all ports and
>> +   device mode for port 2.
>> +
>>  config PHY_CYGNUS_PCIE
>>   tristate "Broadcom Cygnus PCIe PHY driver"
>>   depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
>> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
>> index 4eb82ec..3dec23c 100644
>> --- a/drivers/phy/broadcom/Makefile
>> +++ b/drivers/phy/broadcom/Makefile
>> @@ -1,4 +1,5 @@
>>  obj-$(CONFIG_PHY_CYGNUS_PCIE)+= phy-bcm-cygnus-pcie.o
>> +obj-$(CONFIG_PHY_BCM_CYGNUS_USB) += phy-bcm-cygnus-usb.o
>>  obj-$(CONFIG_BCM_KONA_USB2_PHY)  += phy-bcm-kona-usb2.o
>>  obj-$(CONFIG_PHY_BCM_NS_USB2)+= phy-bcm-ns-usb2.o
>>  obj-$(CONFIG_PHY_BCM_NS_USB3)+= phy-bcm-ns-usb3.o
>> diff --git a/drivers/phy/broadcom/phy-bcm-cygnus-usb.c 
>> b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>> new file mode 100644
>> index 000..ef2a94c
>> --- /dev/null
>> +++ b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
>> @@ -0,0 +1,672 @@
>> +/*
>> + * Copyright 2017 Broadcom
>> + *
>> + * 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 (the "GPL").
>> + *
>> + * This program is distributed in the hope that it will be useful, but
>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * General Public License version 2 (GPLv2) for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * version 2 (GPLv2) along with this source code.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define CDRU_USBPHY_CLK_RST_SEL_OFFSET   0x0
>> +#define CDRU_USBPHY2_HOST_DEV_SEL_OFFSET 0x4
>> +#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_OFFSET  0x5C
>> +#define CDRU_USBPHY_P0_STATUS_OFFSET 0x1C
>> +#define CDRU_USBPHY_P1_STATUS_OFFSET 0x34
>> +#define CDRU_USBPHY_P2_STATUS_OFFSET 0x4C
>
> Looks like it has 2 different blocks; CDRU and CMRU. Having a comment for each
> of the block will help.

Ok, I will fix it in the next version of the patch.

>> +#define CRMU_USB_PHY_AON_CTRL_OFFSET

Re: [PATCH 1/3] Documentation: DT: Add Cygnus usb phy binding

2017-10-26 Thread Raveendra Padasalagi
Hi Rob,

On Fri, Oct 27, 2017 at 9:09 AM, Rob Herring <r...@kernel.org> wrote:
> On Tue, Oct 24, 2017 at 10:07:00AM +0530, Raveendra Padasalagi wrote:
>> Add devicetree binding document for broadcom's
>> Cygnus SoC specific usb phy controller driver.
>
> "dt-bindings: phy: ..." for the subject please.

Ok. I will update it in the next patch set version.

>>
>> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
>> ---
>>  .../bindings/phy/brcm,cygnus-usb-phy.txt   | 101 
>> +
>>  1 file changed, 101 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>>
>> diff --git a/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt 
>> b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>> new file mode 100644
>> index 000..2d99fea
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>> @@ -0,0 +1,101 @@
>> +BROADCOM CYGNUS USB PHY
>> +
>> +Required Properties:
>> +- compatible:  brcm,cygnus-usb-phy
>> +- reg : the register start address and length for crmu_usbphy_aon_ctrl,
>> +  cdru usb phy control and reset registers, usb host idm registers,
>> +  usb device idm registers.
>
> Make this list 1 per line.
Ok
>> +- reg-names: a list of the names corresponding to the previous register
>> +  ranges. Should contain "crmu-usbphy-aon-ctrl", "cdru-usbphy",
>> +  "usb2h-idm", "usb2d-idm".
>> +- address-cells: should be 1
>> +- size-cells: should be 0
>> +
>> +Sub-nodes:
>> +  Each port's PHY should be represented as a sub-node.
>> +
>> +Sub-nodes required properties:
>> +- reg: the PHY number
>> +- #phy-cells must be 1
>> +  The node that uses the phy must provide 1 integer argument specifying
>> +  port number.
>
> Either you need to move #phy-cells up a level or #phy-cells should be 0.
Ok
>> +
>> +Optional Properties:
>> +- vbus-p#-supply : The regulator for vbus out control for the host
>> +  functionality enabled ports.
>> +- vbus-gpios: vbus gpio binding
>
> Are you using these or extcon?
Yes, using extcon in phy driver to receive USB Device/Host connect/disconnect
notifications.

> Don't use extcon. It needs to be redesigned and I don't want to see new
> users.

Without extcon I need to duplicate the code in phy driver to implement
extcon functionality,
which is again bad. Once the extcon redesign is done may be we can
adopt the changes in
this driver at that time.

>> +  This is mandatory for port 2, as port 2 is used as dual role phy.
>> +  Based on the vbus and id values device or host role is determined
>> +  for phy 2.
>> +
>> +- extcon: extcon phandle
>> +  This is mandatory for port 2,  as port 2 is used as dual role phy.
>> +  extcon should be phandle to external usb gpio module which provide
>> +  device or host role notifications based on the ID and VBUS gpio's state.
>> +
>> +
>> +Refer to phy/phy-bindings.txt for the generic PHY binding properties
>> +
>> +NOTE: port 0 and port 1 are host only and port 2 is dual role port.
>> +
>> +Example of phy :
>> + usbphy: phy@0301c028 {
>
> usb-phy@301c028
>
>> + compatible = "brcm,cygnus-usb-phy";
>> + reg = <0x0301c028 0x4>,
>> +   <0x0301d1b4 0x5c>,
>> +   <0x18115000 0xa00>,
>> +   <0x18111000 0xa00>;
>> + reg-names = "crmu-usbphy-aon-ctrl", "cdru-usbphy",
>> + "usb2h-idm", "usb2d-idm";
>> + #address-cells = <1>;
>> + #size-cells = <0>;
>> +
>> + usbphy0: usb-phy@0 {
>> + reg = <0>;
>> + #phy-cells = <1>;
>> + };
>> +
>> + usbphy1: usb-phy@1 {
>> + reg = <1>;
>> + #phy-cells = <1>;
>> + };
>> +
>> + usbphy2: usb-phy@2 {
>> + reg = <2>;
>> + #phy-cells = <1>;
>> + extcon = <_usb>;
>> + };
>> + };
>> +
>> + extcon_usb: extcon_usb {
>> + compatible = "linux,extcon-usb-gpio";
>> + vbus-gpio = <_asiu 121 0>;
>> + id-gpio = <_asiu 122 0>;
&

Re: [PATCH 1/3] Documentation: DT: Add Cygnus usb phy binding

2017-10-26 Thread Raveendra Padasalagi
Hi Rob,

On Fri, Oct 27, 2017 at 9:09 AM, Rob Herring  wrote:
> On Tue, Oct 24, 2017 at 10:07:00AM +0530, Raveendra Padasalagi wrote:
>> Add devicetree binding document for broadcom's
>> Cygnus SoC specific usb phy controller driver.
>
> "dt-bindings: phy: ..." for the subject please.

Ok. I will update it in the next patch set version.

>>
>> Signed-off-by: Raveendra Padasalagi 
>> ---
>>  .../bindings/phy/brcm,cygnus-usb-phy.txt   | 101 
>> +
>>  1 file changed, 101 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>>
>> diff --git a/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt 
>> b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>> new file mode 100644
>> index 000..2d99fea
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
>> @@ -0,0 +1,101 @@
>> +BROADCOM CYGNUS USB PHY
>> +
>> +Required Properties:
>> +- compatible:  brcm,cygnus-usb-phy
>> +- reg : the register start address and length for crmu_usbphy_aon_ctrl,
>> +  cdru usb phy control and reset registers, usb host idm registers,
>> +  usb device idm registers.
>
> Make this list 1 per line.
Ok
>> +- reg-names: a list of the names corresponding to the previous register
>> +  ranges. Should contain "crmu-usbphy-aon-ctrl", "cdru-usbphy",
>> +  "usb2h-idm", "usb2d-idm".
>> +- address-cells: should be 1
>> +- size-cells: should be 0
>> +
>> +Sub-nodes:
>> +  Each port's PHY should be represented as a sub-node.
>> +
>> +Sub-nodes required properties:
>> +- reg: the PHY number
>> +- #phy-cells must be 1
>> +  The node that uses the phy must provide 1 integer argument specifying
>> +  port number.
>
> Either you need to move #phy-cells up a level or #phy-cells should be 0.
Ok
>> +
>> +Optional Properties:
>> +- vbus-p#-supply : The regulator for vbus out control for the host
>> +  functionality enabled ports.
>> +- vbus-gpios: vbus gpio binding
>
> Are you using these or extcon?
Yes, using extcon in phy driver to receive USB Device/Host connect/disconnect
notifications.

> Don't use extcon. It needs to be redesigned and I don't want to see new
> users.

Without extcon I need to duplicate the code in phy driver to implement
extcon functionality,
which is again bad. Once the extcon redesign is done may be we can
adopt the changes in
this driver at that time.

>> +  This is mandatory for port 2, as port 2 is used as dual role phy.
>> +  Based on the vbus and id values device or host role is determined
>> +  for phy 2.
>> +
>> +- extcon: extcon phandle
>> +  This is mandatory for port 2,  as port 2 is used as dual role phy.
>> +  extcon should be phandle to external usb gpio module which provide
>> +  device or host role notifications based on the ID and VBUS gpio's state.
>> +
>> +
>> +Refer to phy/phy-bindings.txt for the generic PHY binding properties
>> +
>> +NOTE: port 0 and port 1 are host only and port 2 is dual role port.
>> +
>> +Example of phy :
>> + usbphy: phy@0301c028 {
>
> usb-phy@301c028
>
>> + compatible = "brcm,cygnus-usb-phy";
>> + reg = <0x0301c028 0x4>,
>> +   <0x0301d1b4 0x5c>,
>> +   <0x18115000 0xa00>,
>> +   <0x18111000 0xa00>;
>> + reg-names = "crmu-usbphy-aon-ctrl", "cdru-usbphy",
>> + "usb2h-idm", "usb2d-idm";
>> + #address-cells = <1>;
>> + #size-cells = <0>;
>> +
>> + usbphy0: usb-phy@0 {
>> + reg = <0>;
>> + #phy-cells = <1>;
>> + };
>> +
>> + usbphy1: usb-phy@1 {
>> + reg = <1>;
>> + #phy-cells = <1>;
>> + };
>> +
>> + usbphy2: usb-phy@2 {
>> + reg = <2>;
>> + #phy-cells = <1>;
>> + extcon = <_usb>;
>> + };
>> + };
>> +
>> + extcon_usb: extcon_usb {
>> + compatible = "linux,extcon-usb-gpio";
>> + vbus-gpio = <_asiu 121 0>;
>> + id-gpio = <_asiu 122 0>;
>> + status = "okay";
&g

Re: [PATCH 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-10-24 Thread Raveendra Padasalagi
On Tue, Oct 24, 2017 at 11:16 AM, Rafał Miłecki <ra...@milecki.pl> wrote:
> On 2017-10-24 06:37, Raveendra Padasalagi wrote:
>>
>> Add driver for Broadcom's USB phy controller's used in Cygnus
>> familyof SoC. Cygnus has three USB phy controller's, port 0,
>> port 1 provides USB host functionality and port 2 can be configured
>> for host/device role.
>>
>> Configuration of host/device role for port 2 is achieved based on
>> the extcon events, the driver registers to extcon framework to get
>> appropriate connect events for Host/Device cables connect/disconnect
>> states based on VBUS and ID interrupts.
>
>
> Minor issues commented inline.
>
>
>> +#define USB2_IDM_IDM_IO_CONTROL_DIRECT_OFFSET  0x0408
>> +#define USB2_IDM_IDM_IO_CONTROL_DIRECT_CLK_ENABLE  BIT(0)
>
>
> Here you define reg bits using BIT(n).
>
>
>> +#define SUSPEND_OVERRIDE_0 13
>> +#define SUSPEND_OVERRIDE_1 14
>> +#define SUSPEND_OVERRIDE_2 15
>> +#define USB2_IDM_IDM_RESET_CONTROL_OFFSET  0x0800
>> +#define USB2_IDM_IDM_RESET_CONTROL__RESET  0
>
>
> And here without BIT(n). Either is fine but it may be better to be
> consistent about it.

Thanks, will fix it in the next version of the patch.

>
>
>> +static int cygnus_phy_probe(struct platform_device *pdev)
>> +{
>> +   struct resource *res;
>> +   struct cygnus_phy_driver *phy_driver;
>> +   struct phy_provider *phy_provider;
>> +   int i, ret;
>> +   u32 reg_val;
>> +   struct device *dev = >dev;
>> +   struct device_node *node = dev->of_node;
>> +
>> +   /* allocate memory for each phy instance */
>> +   phy_driver = devm_kzalloc(dev, sizeof(struct cygnus_phy_driver),
>> + GFP_KERNEL);
>> +   if (!phy_driver)
>> +   return -ENOMEM;
>> +
>> +   phy_driver->num_phys = of_get_child_count(node);
>> +
>> +   if (phy_driver->num_phys == 0) {
>> +   dev_err(dev, "PHY no child node\n");
>> +   return -ENODEV;
>> +   }
>> +
>> +   phy_driver->instances = devm_kcalloc(dev, phy_driver->num_phys,
>> +sizeof(struct
>> cygnus_phy_instance),
>> +GFP_KERNEL);
>
>
> I don't think kcalloc is safe here. E.g. In cygnus_phy_shutdown you
> iterate over all instances reading the .power value. If
> cygnus_phy_shutdown gets called before having each instance powered up,
> you'll read random memory as .power value.

Yes, Need to use devm_kzalloc() to make sure contents of
phy_driver->instances is zero initialized.
Will fix it in the next patch.


Re: [PATCH 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-10-24 Thread Raveendra Padasalagi
On Tue, Oct 24, 2017 at 11:16 AM, Rafał Miłecki  wrote:
> On 2017-10-24 06:37, Raveendra Padasalagi wrote:
>>
>> Add driver for Broadcom's USB phy controller's used in Cygnus
>> familyof SoC. Cygnus has three USB phy controller's, port 0,
>> port 1 provides USB host functionality and port 2 can be configured
>> for host/device role.
>>
>> Configuration of host/device role for port 2 is achieved based on
>> the extcon events, the driver registers to extcon framework to get
>> appropriate connect events for Host/Device cables connect/disconnect
>> states based on VBUS and ID interrupts.
>
>
> Minor issues commented inline.
>
>
>> +#define USB2_IDM_IDM_IO_CONTROL_DIRECT_OFFSET  0x0408
>> +#define USB2_IDM_IDM_IO_CONTROL_DIRECT_CLK_ENABLE  BIT(0)
>
>
> Here you define reg bits using BIT(n).
>
>
>> +#define SUSPEND_OVERRIDE_0 13
>> +#define SUSPEND_OVERRIDE_1 14
>> +#define SUSPEND_OVERRIDE_2 15
>> +#define USB2_IDM_IDM_RESET_CONTROL_OFFSET  0x0800
>> +#define USB2_IDM_IDM_RESET_CONTROL__RESET  0
>
>
> And here without BIT(n). Either is fine but it may be better to be
> consistent about it.

Thanks, will fix it in the next version of the patch.

>
>
>> +static int cygnus_phy_probe(struct platform_device *pdev)
>> +{
>> +   struct resource *res;
>> +   struct cygnus_phy_driver *phy_driver;
>> +   struct phy_provider *phy_provider;
>> +   int i, ret;
>> +   u32 reg_val;
>> +   struct device *dev = >dev;
>> +   struct device_node *node = dev->of_node;
>> +
>> +   /* allocate memory for each phy instance */
>> +   phy_driver = devm_kzalloc(dev, sizeof(struct cygnus_phy_driver),
>> + GFP_KERNEL);
>> +   if (!phy_driver)
>> +   return -ENOMEM;
>> +
>> +   phy_driver->num_phys = of_get_child_count(node);
>> +
>> +   if (phy_driver->num_phys == 0) {
>> +   dev_err(dev, "PHY no child node\n");
>> +   return -ENODEV;
>> +   }
>> +
>> +   phy_driver->instances = devm_kcalloc(dev, phy_driver->num_phys,
>> +sizeof(struct
>> cygnus_phy_instance),
>> +GFP_KERNEL);
>
>
> I don't think kcalloc is safe here. E.g. In cygnus_phy_shutdown you
> iterate over all instances reading the .power value. If
> cygnus_phy_shutdown gets called before having each instance powered up,
> you'll read random memory as .power value.

Yes, Need to use devm_kzalloc() to make sure contents of
phy_driver->instances is zero initialized.
Will fix it in the next patch.


[PATCH 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-10-23 Thread Raveendra Padasalagi
Add driver for Broadcom's USB phy controller's used in Cygnus
familyof SoC. Cygnus has three USB phy controller's, port 0,
port 1 provides USB host functionality and port 2 can be configured
for host/device role.

Configuration of host/device role for port 2 is achieved based on
the extcon events, the driver registers to extcon framework to get
appropriate connect events for Host/Device cables connect/disconnect
states based on VBUS and ID interrupts.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
---
 drivers/phy/broadcom/Kconfig  |  14 +
 drivers/phy/broadcom/Makefile |   1 +
 drivers/phy/broadcom/phy-bcm-cygnus-usb.c | 672 ++
 3 files changed, 687 insertions(+)
 create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c

diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
index 64fc59c..3179daf 100644
--- a/drivers/phy/broadcom/Kconfig
+++ b/drivers/phy/broadcom/Kconfig
@@ -1,6 +1,20 @@
 #
 # Phy drivers for Broadcom platforms
 #
+config PHY_BCM_CYGNUS_USB
+   tristate "Broadcom Cygnus USB PHY support"
+   depends on OF
+   depends on ARCH_BCM_CYGNUS || COMPILE_TEST
+   select GENERIC_PHY
+   select EXTCON_USB_GPIO
+   default ARCH_BCM_CYGNUS
+   help
+ Enable this to support three USB PHY's present in Broadcom's
+ Cygnus chip.
+
+ The phys are capable of supporting host mode on all ports and
+ device mode for port 2.
+
 config PHY_CYGNUS_PCIE
tristate "Broadcom Cygnus PCIe PHY driver"
depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
index 4eb82ec..3dec23c 100644
--- a/drivers/phy/broadcom/Makefile
+++ b/drivers/phy/broadcom/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_PHY_CYGNUS_PCIE)  += phy-bcm-cygnus-pcie.o
+obj-$(CONFIG_PHY_BCM_CYGNUS_USB)   += phy-bcm-cygnus-usb.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB2)  += phy-bcm-ns-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB3)  += phy-bcm-ns-usb3.o
diff --git a/drivers/phy/broadcom/phy-bcm-cygnus-usb.c 
b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
new file mode 100644
index 000..ef2a94c
--- /dev/null
+++ b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
@@ -0,0 +1,672 @@
+/*
+ * Copyright 2017 Broadcom
+ *
+ * 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 (the "GPL").
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 (GPLv2) for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 (GPLv2) along with this source code.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define CDRU_USBPHY_CLK_RST_SEL_OFFSET 0x0
+#define CDRU_USBPHY2_HOST_DEV_SEL_OFFSET   0x4
+#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_OFFSET0x5C
+#define CDRU_USBPHY_P0_STATUS_OFFSET   0x1C
+#define CDRU_USBPHY_P1_STATUS_OFFSET   0x34
+#define CDRU_USBPHY_P2_STATUS_OFFSET   0x4C
+#define CRMU_USB_PHY_AON_CTRL_OFFSET   0x0
+
+#define CDRU_USBPHY_USBPHY_ILDO_ON_FLAGBIT(1)
+#define CDRU_USBPHY_USBPHY_PLL_LOCKBIT(0)
+#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_DISABLE   BIT(0)
+
+#define PHY2_DEV_HOST_CTRL_SEL_DEVICE  0
+#define PHY2_DEV_HOST_CTRL_SEL_HOST1
+#define PHY2_DEV_HOST_CTRL_SEL_IDLE2
+#define CRMU_USBPHY_P0_AFE_CORERDY_VDDCBIT(1)
+#define CRMU_USBPHY_P0_RESETB  BIT(2)
+#define CRMU_USBPHY_P1_AFE_CORERDY_VDDCBIT(9)
+#define CRMU_USBPHY_P1_RESETB  BIT(10)
+#define CRMU_USBPHY_P2_AFE_CORERDY_VDDCBIT(17)
+#define CRMU_USBPHY_P2_RESETB  BIT(18)
+
+#define USB2_IDM_IDM_IO_CONTROL_DIRECT_OFFSET  0x0408
+#define USB2_IDM_IDM_IO_CONTROL_DIRECT_CLK_ENABLE  BIT(0)
+#define SUSPEND_OVERRIDE_0 13
+#define SUSPEND_OVERRIDE_1 14
+#define SUSPEND_OVERRIDE_2 15
+#define USB2_IDM_IDM_RESET_CONTROL_OFFSET  0x0800
+#define USB2_IDM_IDM_RESET_CONTROL__RESET  0
+#define USB2D_IDM_IDM_IO_SS_CLEAR_NAK_NEMPTY_EN_I  BIT(24)
+
+#define PLL_LOCK_RETRY_COUNT   1000
+#define MAX_REGULATOR_

[PATCH 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller

2017-10-23 Thread Raveendra Padasalagi
Add driver for Broadcom's USB phy controller's used in Cygnus
familyof SoC. Cygnus has three USB phy controller's, port 0,
port 1 provides USB host functionality and port 2 can be configured
for host/device role.

Configuration of host/device role for port 2 is achieved based on
the extcon events, the driver registers to extcon framework to get
appropriate connect events for Host/Device cables connect/disconnect
states based on VBUS and ID interrupts.

Signed-off-by: Raveendra Padasalagi 
---
 drivers/phy/broadcom/Kconfig  |  14 +
 drivers/phy/broadcom/Makefile |   1 +
 drivers/phy/broadcom/phy-bcm-cygnus-usb.c | 672 ++
 3 files changed, 687 insertions(+)
 create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c

diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
index 64fc59c..3179daf 100644
--- a/drivers/phy/broadcom/Kconfig
+++ b/drivers/phy/broadcom/Kconfig
@@ -1,6 +1,20 @@
 #
 # Phy drivers for Broadcom platforms
 #
+config PHY_BCM_CYGNUS_USB
+   tristate "Broadcom Cygnus USB PHY support"
+   depends on OF
+   depends on ARCH_BCM_CYGNUS || COMPILE_TEST
+   select GENERIC_PHY
+   select EXTCON_USB_GPIO
+   default ARCH_BCM_CYGNUS
+   help
+ Enable this to support three USB PHY's present in Broadcom's
+ Cygnus chip.
+
+ The phys are capable of supporting host mode on all ports and
+ device mode for port 2.
+
 config PHY_CYGNUS_PCIE
tristate "Broadcom Cygnus PCIe PHY driver"
depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
index 4eb82ec..3dec23c 100644
--- a/drivers/phy/broadcom/Makefile
+++ b/drivers/phy/broadcom/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_PHY_CYGNUS_PCIE)  += phy-bcm-cygnus-pcie.o
+obj-$(CONFIG_PHY_BCM_CYGNUS_USB)   += phy-bcm-cygnus-usb.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB2)  += phy-bcm-ns-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB3)  += phy-bcm-ns-usb3.o
diff --git a/drivers/phy/broadcom/phy-bcm-cygnus-usb.c 
b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
new file mode 100644
index 000..ef2a94c
--- /dev/null
+++ b/drivers/phy/broadcom/phy-bcm-cygnus-usb.c
@@ -0,0 +1,672 @@
+/*
+ * Copyright 2017 Broadcom
+ *
+ * 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 (the "GPL").
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 (GPLv2) for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 (GPLv2) along with this source code.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define CDRU_USBPHY_CLK_RST_SEL_OFFSET 0x0
+#define CDRU_USBPHY2_HOST_DEV_SEL_OFFSET   0x4
+#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_OFFSET0x5C
+#define CDRU_USBPHY_P0_STATUS_OFFSET   0x1C
+#define CDRU_USBPHY_P1_STATUS_OFFSET   0x34
+#define CDRU_USBPHY_P2_STATUS_OFFSET   0x4C
+#define CRMU_USB_PHY_AON_CTRL_OFFSET   0x0
+
+#define CDRU_USBPHY_USBPHY_ILDO_ON_FLAGBIT(1)
+#define CDRU_USBPHY_USBPHY_PLL_LOCKBIT(0)
+#define CDRU_USB_DEV_SUSPEND_RESUME_CTRL_DISABLE   BIT(0)
+
+#define PHY2_DEV_HOST_CTRL_SEL_DEVICE  0
+#define PHY2_DEV_HOST_CTRL_SEL_HOST1
+#define PHY2_DEV_HOST_CTRL_SEL_IDLE2
+#define CRMU_USBPHY_P0_AFE_CORERDY_VDDCBIT(1)
+#define CRMU_USBPHY_P0_RESETB  BIT(2)
+#define CRMU_USBPHY_P1_AFE_CORERDY_VDDCBIT(9)
+#define CRMU_USBPHY_P1_RESETB  BIT(10)
+#define CRMU_USBPHY_P2_AFE_CORERDY_VDDCBIT(17)
+#define CRMU_USBPHY_P2_RESETB  BIT(18)
+
+#define USB2_IDM_IDM_IO_CONTROL_DIRECT_OFFSET  0x0408
+#define USB2_IDM_IDM_IO_CONTROL_DIRECT_CLK_ENABLE  BIT(0)
+#define SUSPEND_OVERRIDE_0 13
+#define SUSPEND_OVERRIDE_1 14
+#define SUSPEND_OVERRIDE_2 15
+#define USB2_IDM_IDM_RESET_CONTROL_OFFSET  0x0800
+#define USB2_IDM_IDM_RESET_CONTROL__RESET  0
+#define USB2D_IDM_IDM_IO_SS_CLEAR_NAK_NEMPTY_EN_I  BIT(24)
+
+#define PLL_LOCK_RETRY_COUNT   1000
+#define MAX_REGULATOR_NAME_LEN

[PATCH 3/3] ARM: dts: Add dt node for Broadcom Cygnus USB phy

2017-10-23 Thread Raveendra Padasalagi
Add DT node for Broadcom's USB phy controller's used
in Cygnus family of SoC.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
---
 arch/arm/boot/dts/bcm-cygnus.dtsi | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi 
b/arch/arm/boot/dts/bcm-cygnus.dtsi
index 7c957ea..810df68 100644
--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
+++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
@@ -96,6 +96,41 @@
#address-cells = <1>;
#size-cells = <1>;
 
+   extcon_usb: extcon_usb {
+   compatible = "linux,extcon-usb-gpio";
+   vbus-gpio = <_asiu 121 0>;
+   id-gpio = <_asiu 122 0>;
+   status = "okay";
+   };
+
+   usbphy: phy@0301c028 {
+   compatible = "brcm,cygnus-usb-phy";
+   reg = <0x0301c028 0x4>,
+ <0x0301d1b4 0x5c>,
+ <0x18115000 0xa00>,
+ <0x18111000 0xa00>;
+   reg-names = "crmu-usbphy-aon-ctrl", "cdru-usbphy",
+   "usb2h-idm", "usb2d-idm";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   usbphy0: usb-phy@0 {
+   #phy-cells = <1>;
+   reg = <0>;
+   };
+
+   usbphy1: usb-phy@1 {
+   #phy-cells = <1>;
+   reg = <1>;
+   };
+
+   usbphy2: usb-phy@2 {
+   #phy-cells = <1>;
+   reg = <2>;
+   extcon = <_usb>;
+   };
+   };
+
otp: otp@0301c800 {
compatible = "brcm,ocotp";
reg = <0x0301c800 0x2c>;
-- 
1.9.1



[PATCH 3/3] ARM: dts: Add dt node for Broadcom Cygnus USB phy

2017-10-23 Thread Raveendra Padasalagi
Add DT node for Broadcom's USB phy controller's used
in Cygnus family of SoC.

Signed-off-by: Raveendra Padasalagi 
---
 arch/arm/boot/dts/bcm-cygnus.dtsi | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi 
b/arch/arm/boot/dts/bcm-cygnus.dtsi
index 7c957ea..810df68 100644
--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
+++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
@@ -96,6 +96,41 @@
#address-cells = <1>;
#size-cells = <1>;
 
+   extcon_usb: extcon_usb {
+   compatible = "linux,extcon-usb-gpio";
+   vbus-gpio = <_asiu 121 0>;
+   id-gpio = <_asiu 122 0>;
+   status = "okay";
+   };
+
+   usbphy: phy@0301c028 {
+   compatible = "brcm,cygnus-usb-phy";
+   reg = <0x0301c028 0x4>,
+ <0x0301d1b4 0x5c>,
+ <0x18115000 0xa00>,
+ <0x18111000 0xa00>;
+   reg-names = "crmu-usbphy-aon-ctrl", "cdru-usbphy",
+   "usb2h-idm", "usb2d-idm";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   usbphy0: usb-phy@0 {
+   #phy-cells = <1>;
+   reg = <0>;
+   };
+
+   usbphy1: usb-phy@1 {
+   #phy-cells = <1>;
+   reg = <1>;
+   };
+
+   usbphy2: usb-phy@2 {
+   #phy-cells = <1>;
+   reg = <2>;
+   extcon = <_usb>;
+   };
+   };
+
otp: otp@0301c800 {
compatible = "brcm,ocotp";
reg = <0x0301c800 0x2c>;
-- 
1.9.1



[PATCH 1/3] Documentation: DT: Add Cygnus usb phy binding

2017-10-23 Thread Raveendra Padasalagi
Add devicetree binding document for broadcom's
Cygnus SoC specific usb phy controller driver.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
---
 .../bindings/phy/brcm,cygnus-usb-phy.txt   | 101 +
 1 file changed, 101 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt 
b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
new file mode 100644
index 000..2d99fea
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
@@ -0,0 +1,101 @@
+BROADCOM CYGNUS USB PHY
+
+Required Properties:
+- compatible:  brcm,cygnus-usb-phy
+- reg : the register start address and length for crmu_usbphy_aon_ctrl,
+  cdru usb phy control and reset registers, usb host idm registers,
+  usb device idm registers.
+- reg-names: a list of the names corresponding to the previous register
+  ranges. Should contain "crmu-usbphy-aon-ctrl", "cdru-usbphy",
+  "usb2h-idm", "usb2d-idm".
+- address-cells: should be 1
+- size-cells: should be 0
+
+Sub-nodes:
+  Each port's PHY should be represented as a sub-node.
+
+Sub-nodes required properties:
+- reg: the PHY number
+- #phy-cells must be 1
+  The node that uses the phy must provide 1 integer argument specifying
+  port number.
+
+Optional Properties:
+- vbus-p#-supply : The regulator for vbus out control for the host
+  functionality enabled ports.
+- vbus-gpios: vbus gpio binding
+  This is mandatory for port 2, as port 2 is used as dual role phy.
+  Based on the vbus and id values device or host role is determined
+  for phy 2.
+
+- extcon: extcon phandle
+  This is mandatory for port 2,  as port 2 is used as dual role phy.
+  extcon should be phandle to external usb gpio module which provide
+  device or host role notifications based on the ID and VBUS gpio's state.
+
+
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+NOTE: port 0 and port 1 are host only and port 2 is dual role port.
+
+Example of phy :
+   usbphy: phy@0301c028 {
+   compatible = "brcm,cygnus-usb-phy";
+   reg = <0x0301c028 0x4>,
+ <0x0301d1b4 0x5c>,
+ <0x18115000 0xa00>,
+ <0x18111000 0xa00>;
+   reg-names = "crmu-usbphy-aon-ctrl", "cdru-usbphy",
+   "usb2h-idm", "usb2d-idm";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   usbphy0: usb-phy@0 {
+   reg = <0>;
+   #phy-cells = <1>;
+   };
+
+   usbphy1: usb-phy@1 {
+   reg = <1>;
+   #phy-cells = <1>;
+   };
+
+   usbphy2: usb-phy@2 {
+   reg = <2>;
+   #phy-cells = <1>;
+   extcon = <_usb>;
+   };
+   };
+
+   extcon_usb: extcon_usb {
+   compatible = "linux,extcon-usb-gpio";
+   vbus-gpio = <_asiu 121 0>;
+   id-gpio = <_asiu 122 0>;
+   status = "okay";
+   };
+
+
+Example of node using the phy:
+
+   /* This nodes declares all three ports, port 0
+   and port 1 are host and port 2 is device */
+
+   ehci0: usb@18048000 {
+   compatible = "generic-ehci";
+   reg = <0x18048000 0x100>;
+   interrupts = ;
+   phys = < 0  1  2>;
+   phy-names = "usbp0","usbp1","usbp2";
+   status = "okay";
+   };
+
+   /* This node declares port 2 phy
+   and configures it for device */
+
+   usbd_udc_dwc1: usbd_udc_dwc@1804c000 {
+   compatible = "iproc-udc";
+   reg = <0x1804c000 0x2000>;
+   interrupts = ;
+   phys = < 2>;
+   phy-names = "usbdrd";
+   };
-- 
1.9.1



[PATCH 0/3] Add driver for Broadcom Cygnus USB phy controller

2017-10-23 Thread Raveendra Padasalagi
Add driver for Broadcom's USB phy controller's used in Cygnus family
of SoC and it's based on 4.14-rc3 tag.

The patch set can be fetched from iproc-cyg-usb-v1 branch of
https://github.com/Broadcom/arm64-linux.git

Raveendra Padasalagi (3):
  Documentation: DT: Add Cygnus usb phy binding
  drivers: phy: broadcom: Add driver for Cygnus USB phy controller
  ARM: dts: Add dt node for Broadcom Cygnus USB phy

 .../bindings/phy/brcm,cygnus-usb-phy.txt   | 101 
 arch/arm/boot/dts/bcm-cygnus.dtsi  |  35 ++
 drivers/phy/broadcom/Kconfig   |  14 +
 drivers/phy/broadcom/Makefile  |   1 +
 drivers/phy/broadcom/phy-bcm-cygnus-usb.c  | 672 +
 5 files changed, 823 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
 create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c

-- 
1.9.1



[PATCH 1/3] Documentation: DT: Add Cygnus usb phy binding

2017-10-23 Thread Raveendra Padasalagi
Add devicetree binding document for broadcom's
Cygnus SoC specific usb phy controller driver.

Signed-off-by: Raveendra Padasalagi 
---
 .../bindings/phy/brcm,cygnus-usb-phy.txt   | 101 +
 1 file changed, 101 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt 
b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
new file mode 100644
index 000..2d99fea
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
@@ -0,0 +1,101 @@
+BROADCOM CYGNUS USB PHY
+
+Required Properties:
+- compatible:  brcm,cygnus-usb-phy
+- reg : the register start address and length for crmu_usbphy_aon_ctrl,
+  cdru usb phy control and reset registers, usb host idm registers,
+  usb device idm registers.
+- reg-names: a list of the names corresponding to the previous register
+  ranges. Should contain "crmu-usbphy-aon-ctrl", "cdru-usbphy",
+  "usb2h-idm", "usb2d-idm".
+- address-cells: should be 1
+- size-cells: should be 0
+
+Sub-nodes:
+  Each port's PHY should be represented as a sub-node.
+
+Sub-nodes required properties:
+- reg: the PHY number
+- #phy-cells must be 1
+  The node that uses the phy must provide 1 integer argument specifying
+  port number.
+
+Optional Properties:
+- vbus-p#-supply : The regulator for vbus out control for the host
+  functionality enabled ports.
+- vbus-gpios: vbus gpio binding
+  This is mandatory for port 2, as port 2 is used as dual role phy.
+  Based on the vbus and id values device or host role is determined
+  for phy 2.
+
+- extcon: extcon phandle
+  This is mandatory for port 2,  as port 2 is used as dual role phy.
+  extcon should be phandle to external usb gpio module which provide
+  device or host role notifications based on the ID and VBUS gpio's state.
+
+
+Refer to phy/phy-bindings.txt for the generic PHY binding properties
+
+NOTE: port 0 and port 1 are host only and port 2 is dual role port.
+
+Example of phy :
+   usbphy: phy@0301c028 {
+   compatible = "brcm,cygnus-usb-phy";
+   reg = <0x0301c028 0x4>,
+ <0x0301d1b4 0x5c>,
+ <0x18115000 0xa00>,
+ <0x18111000 0xa00>;
+   reg-names = "crmu-usbphy-aon-ctrl", "cdru-usbphy",
+   "usb2h-idm", "usb2d-idm";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   usbphy0: usb-phy@0 {
+   reg = <0>;
+   #phy-cells = <1>;
+   };
+
+   usbphy1: usb-phy@1 {
+   reg = <1>;
+   #phy-cells = <1>;
+   };
+
+   usbphy2: usb-phy@2 {
+   reg = <2>;
+   #phy-cells = <1>;
+   extcon = <_usb>;
+   };
+   };
+
+   extcon_usb: extcon_usb {
+   compatible = "linux,extcon-usb-gpio";
+   vbus-gpio = <_asiu 121 0>;
+   id-gpio = <_asiu 122 0>;
+   status = "okay";
+   };
+
+
+Example of node using the phy:
+
+   /* This nodes declares all three ports, port 0
+   and port 1 are host and port 2 is device */
+
+   ehci0: usb@18048000 {
+   compatible = "generic-ehci";
+   reg = <0x18048000 0x100>;
+   interrupts = ;
+   phys = < 0  1  2>;
+   phy-names = "usbp0","usbp1","usbp2";
+   status = "okay";
+   };
+
+   /* This node declares port 2 phy
+   and configures it for device */
+
+   usbd_udc_dwc1: usbd_udc_dwc@1804c000 {
+   compatible = "iproc-udc";
+   reg = <0x1804c000 0x2000>;
+   interrupts = ;
+   phys = < 2>;
+   phy-names = "usbdrd";
+   };
-- 
1.9.1



[PATCH 0/3] Add driver for Broadcom Cygnus USB phy controller

2017-10-23 Thread Raveendra Padasalagi
Add driver for Broadcom's USB phy controller's used in Cygnus family
of SoC and it's based on 4.14-rc3 tag.

The patch set can be fetched from iproc-cyg-usb-v1 branch of
https://github.com/Broadcom/arm64-linux.git

Raveendra Padasalagi (3):
  Documentation: DT: Add Cygnus usb phy binding
  drivers: phy: broadcom: Add driver for Cygnus USB phy controller
  ARM: dts: Add dt node for Broadcom Cygnus USB phy

 .../bindings/phy/brcm,cygnus-usb-phy.txt   | 101 
 arch/arm/boot/dts/bcm-cygnus.dtsi  |  35 ++
 drivers/phy/broadcom/Kconfig   |  14 +
 drivers/phy/broadcom/Makefile  |   1 +
 drivers/phy/broadcom/phy-bcm-cygnus-usb.c  | 672 +
 5 files changed, 823 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/brcm,cygnus-usb-phy.txt
 create mode 100644 drivers/phy/broadcom/phy-bcm-cygnus-usb.c

-- 
1.9.1



[PATCH v3 1/2] Documentation: dt: extcon: add optional input-debounce attribute

2017-10-19 Thread Raveendra Padasalagi
Add documentation on optional dt attribute "input-debounce"
in extcon node to capture user specified timeout value for id
and vbus gpio detection.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Srinath Mannam <srinath.man...@broadcom.com>
Reviewed-by: Chanwoo Choi <cw00.c...@samsung.com>
---

Changes in v3:
 - Modified commit log to name debounce-timeout-ms to input-debounce
 - Added Reviewed-by: Chanwoo Choi <cw00.c...@samsung.com>

Changes in v2:
 Rename debounce-timeout-ms to input-debounce

 Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt 
b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
index dfc14f7..d115900 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
@@ -10,6 +10,9 @@ Either one of id-gpio or vbus-gpio must be present. Both can 
be present as well.
 - id-gpio: gpio for USB ID pin. See gpio binding.
 - vbus-gpio: gpio for USB VBUS pin.
 
+Optional properties:
+- input-debounce: debounce timeout value for id and vbus gpio in microseconds.
+
 Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
extcon_usb1 {
compatible = "linux,extcon-usb-gpio";
-- 
1.9.1



[PATCH v3 1/2] Documentation: dt: extcon: add optional input-debounce attribute

2017-10-19 Thread Raveendra Padasalagi
Add documentation on optional dt attribute "input-debounce"
in extcon node to capture user specified timeout value for id
and vbus gpio detection.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Srinath Mannam 
Reviewed-by: Chanwoo Choi 
---

Changes in v3:
 - Modified commit log to name debounce-timeout-ms to input-debounce
 - Added Reviewed-by: Chanwoo Choi 

Changes in v2:
 Rename debounce-timeout-ms to input-debounce

 Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt 
b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
index dfc14f7..d115900 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
@@ -10,6 +10,9 @@ Either one of id-gpio or vbus-gpio must be present. Both can 
be present as well.
 - id-gpio: gpio for USB ID pin. See gpio binding.
 - vbus-gpio: gpio for USB VBUS pin.
 
+Optional properties:
+- input-debounce: debounce timeout value for id and vbus gpio in microseconds.
+
 Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
extcon_usb1 {
compatible = "linux,extcon-usb-gpio";
-- 
1.9.1



[PATCH v3 2/2] extcon: add optional input-debounce attribute

2017-10-19 Thread Raveendra Padasalagi
Add changes to capture optional dt attribute "input-debounce"
provided in extcon node and used the same value if provided otherwise
default value of 2 usecs is used for id and vbus gpios debounce time.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Srinath Mannam <srinath.man...@broadcom.com>
---

Changes in v3:
 - Changed USB_GPIO_DEBOUNCE_MS to USB_GPIO_DEBOUNCE_USEC
 - Changed msecs_to_jiffies() to usecs_to_jiffies()

Changes in v2:
 Rename gpio_debounce_timeout_ms to debounce_usecs

 drivers/extcon/extcon-usb-gpio.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index 9c925b0..69149e2 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -28,7 +28,7 @@
 #include 
 #include 
 
-#define USB_GPIO_DEBOUNCE_MS   20  /* ms */
+#define USB_GPIO_DEBOUNCE_USEC 2   /* us */
 
 struct usb_extcon_info {
struct device *dev;
@@ -41,6 +41,7 @@ struct usb_extcon_info {
 
unsigned long debounce_jiffies;
struct delayed_work wq_detcable;
+   unsigned int debounce_usecs;
 };
 
 static const unsigned int usb_extcon_cable[] = {
@@ -133,6 +134,11 @@ static int usb_extcon_probe(struct platform_device *pdev)
if (IS_ERR(info->vbus_gpiod))
return PTR_ERR(info->vbus_gpiod);
 
+   ret = of_property_read_u32(np, "input-debounce",
+>debounce_usecs);
+   if (ret)
+   info->debounce_usecs = USB_GPIO_DEBOUNCE_USEC;
+
info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable);
if (IS_ERR(info->edev)) {
dev_err(dev, "failed to allocate extcon device\n");
@@ -147,13 +153,13 @@ static int usb_extcon_probe(struct platform_device *pdev)
 
if (info->id_gpiod)
ret = gpiod_set_debounce(info->id_gpiod,
-USB_GPIO_DEBOUNCE_MS * 1000);
+info->debounce_usecs);
if (!ret && info->vbus_gpiod)
ret = gpiod_set_debounce(info->vbus_gpiod,
-USB_GPIO_DEBOUNCE_MS * 1000);
+info->debounce_usecs);
 
if (ret < 0)
-   info->debounce_jiffies = msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS);
+   info->debounce_jiffies = usecs_to_jiffies(info->debounce_usecs);
 
INIT_DELAYED_WORK(>wq_detcable, usb_extcon_detect_cable);
 
-- 
1.9.1



[PATCH v3 2/2] extcon: add optional input-debounce attribute

2017-10-19 Thread Raveendra Padasalagi
Add changes to capture optional dt attribute "input-debounce"
provided in extcon node and used the same value if provided otherwise
default value of 2 usecs is used for id and vbus gpios debounce time.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Srinath Mannam 
---

Changes in v3:
 - Changed USB_GPIO_DEBOUNCE_MS to USB_GPIO_DEBOUNCE_USEC
 - Changed msecs_to_jiffies() to usecs_to_jiffies()

Changes in v2:
 Rename gpio_debounce_timeout_ms to debounce_usecs

 drivers/extcon/extcon-usb-gpio.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index 9c925b0..69149e2 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -28,7 +28,7 @@
 #include 
 #include 
 
-#define USB_GPIO_DEBOUNCE_MS   20  /* ms */
+#define USB_GPIO_DEBOUNCE_USEC 2   /* us */
 
 struct usb_extcon_info {
struct device *dev;
@@ -41,6 +41,7 @@ struct usb_extcon_info {
 
unsigned long debounce_jiffies;
struct delayed_work wq_detcable;
+   unsigned int debounce_usecs;
 };
 
 static const unsigned int usb_extcon_cable[] = {
@@ -133,6 +134,11 @@ static int usb_extcon_probe(struct platform_device *pdev)
if (IS_ERR(info->vbus_gpiod))
return PTR_ERR(info->vbus_gpiod);
 
+   ret = of_property_read_u32(np, "input-debounce",
+>debounce_usecs);
+   if (ret)
+   info->debounce_usecs = USB_GPIO_DEBOUNCE_USEC;
+
info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable);
if (IS_ERR(info->edev)) {
dev_err(dev, "failed to allocate extcon device\n");
@@ -147,13 +153,13 @@ static int usb_extcon_probe(struct platform_device *pdev)
 
if (info->id_gpiod)
ret = gpiod_set_debounce(info->id_gpiod,
-USB_GPIO_DEBOUNCE_MS * 1000);
+info->debounce_usecs);
if (!ret && info->vbus_gpiod)
ret = gpiod_set_debounce(info->vbus_gpiod,
-USB_GPIO_DEBOUNCE_MS * 1000);
+info->debounce_usecs);
 
if (ret < 0)
-   info->debounce_jiffies = msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS);
+   info->debounce_jiffies = usecs_to_jiffies(info->debounce_usecs);
 
INIT_DELAYED_WORK(>wq_detcable, usb_extcon_detect_cable);
 
-- 
1.9.1



Re: [PATCH v2 2/2] extcon: add optional debounce-timeout-ms attribute

2017-10-19 Thread Raveendra Padasalagi
Thanks Chanwoo Choi for the comments. Will revise the patch.

Regards,
Raveendra
On Thu, Oct 19, 2017 at 10:52 AM, Chanwoo Choi <cw00.c...@samsung.com> wrote:
> On 2017년 10월 19일 13:59, Chanwoo Choi wrote:
>> Hi,
>>
>> On 2017년 10월 19일 12:26, Raveendra Padasalagi wrote:
>>> Add changes to capture optional dt attribute "debounce-timeout-ms"
>>> provided in extcon node and used the same value if provided otherwise
>>> default value of 20ms is used for id and vbus gpios debounce time.
>>>
>>> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
>>> Reviewed-by: Ray Jui <ray@broadcom.com>
>>> Reviewed-by: Srinath Mannam <srinath.man...@broadcom.com>
>>> ---
>>>
>>> Changes in v2:
>>>  Rename gpio_debounce_timeout_ms to debounce_usecs
>>>
>>>  drivers/extcon/extcon-usb-gpio.c | 12 +---
>>>  1 file changed, 9 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/extcon/extcon-usb-gpio.c 
>>> b/drivers/extcon/extcon-usb-gpio.c
>>> index 9c925b0..76ef1da 100644
>>> --- a/drivers/extcon/extcon-usb-gpio.c
>>> +++ b/drivers/extcon/extcon-usb-gpio.c
>>> @@ -41,6 +41,7 @@ struct usb_extcon_info {
>>>
>>>  unsigned long debounce_jiffies;
>>>  struct delayed_work wq_detcable;
>>> +unsigned int debounce_usecs;
>>>  };
>>>
>>>  static const unsigned int usb_extcon_cable[] = {
>>> @@ -133,6 +134,11 @@ static int usb_extcon_probe(struct platform_device 
>>> *pdev)
>>>  if (IS_ERR(info->vbus_gpiod))
>>>  return PTR_ERR(info->vbus_gpiod);
>>>
>>> +ret = of_property_read_u32(np, "input-debounce",
>>> + >debounce_usecs);
>>> +if (ret)
>>> +info->debounce_usecs = USB_GPIO_DEBOUNCE_MS;
>>
>> The USB_GPIO_DEBOUNCE_MS indicates 20 millisecond.
>> You need to redefine it as following:
>>   -#define USB_GPIO_DEBOUNCE_MS   20  /* ms */
>>   +#define USB_GPIO_DEBOUNCE_USEC 2
>>
>>   info->debounce_usecs = USB_GPIO_DEBOUNCE_USEC;
>>
>> or
>>   info->debounce_usecs = USB_GPIO_DEBOUNCE_MS * 1000;
>>
>>
>>> +
>>>  info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable);
>>>  if (IS_ERR(info->edev)) {
>>>  dev_err(dev, "failed to allocate extcon device\n");
>>> @@ -147,13 +153,13 @@ static int usb_extcon_probe(struct platform_device 
>>> *pdev)
>>>
>>>  if (info->id_gpiod)
>>>  ret = gpiod_set_debounce(info->id_gpiod,
>>> - USB_GPIO_DEBOUNCE_MS * 1000);
>>> + info->debounce_usecs * 1000);
>>
>> The debounce_usecs is already microsecond, You don't need to mutiply with 
>> 1000.
>>
>>
>>>  if (!ret && info->vbus_gpiod)
>>>  ret = gpiod_set_debounce(info->vbus_gpiod,
>>> - USB_GPIO_DEBOUNCE_MS * 1000);
>>> + info->debounce_usecs * 1000);
>
> You don't need to mutiply with 1000.
>
>>>
>>>  if (ret < 0)
>>> -info->debounce_jiffies = 
>>> msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS);
>>> +info->debounce_jiffies = 
>>> msecs_to_jiffies(info->debounce_usecs);
>
> You should you the 'usecs_to_jiffies' because info->debounce_usecs indicates 
> the usec.
>
> --
> Best Regards,
> Chanwoo Choi
> Samsung Electronics


Re: [PATCH v2 2/2] extcon: add optional debounce-timeout-ms attribute

2017-10-19 Thread Raveendra Padasalagi
Thanks Chanwoo Choi for the comments. Will revise the patch.

Regards,
Raveendra
On Thu, Oct 19, 2017 at 10:52 AM, Chanwoo Choi  wrote:
> On 2017년 10월 19일 13:59, Chanwoo Choi wrote:
>> Hi,
>>
>> On 2017년 10월 19일 12:26, Raveendra Padasalagi wrote:
>>> Add changes to capture optional dt attribute "debounce-timeout-ms"
>>> provided in extcon node and used the same value if provided otherwise
>>> default value of 20ms is used for id and vbus gpios debounce time.
>>>
>>> Signed-off-by: Raveendra Padasalagi 
>>> Reviewed-by: Ray Jui 
>>> Reviewed-by: Srinath Mannam 
>>> ---
>>>
>>> Changes in v2:
>>>  Rename gpio_debounce_timeout_ms to debounce_usecs
>>>
>>>  drivers/extcon/extcon-usb-gpio.c | 12 +---
>>>  1 file changed, 9 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/extcon/extcon-usb-gpio.c 
>>> b/drivers/extcon/extcon-usb-gpio.c
>>> index 9c925b0..76ef1da 100644
>>> --- a/drivers/extcon/extcon-usb-gpio.c
>>> +++ b/drivers/extcon/extcon-usb-gpio.c
>>> @@ -41,6 +41,7 @@ struct usb_extcon_info {
>>>
>>>  unsigned long debounce_jiffies;
>>>  struct delayed_work wq_detcable;
>>> +unsigned int debounce_usecs;
>>>  };
>>>
>>>  static const unsigned int usb_extcon_cable[] = {
>>> @@ -133,6 +134,11 @@ static int usb_extcon_probe(struct platform_device 
>>> *pdev)
>>>  if (IS_ERR(info->vbus_gpiod))
>>>  return PTR_ERR(info->vbus_gpiod);
>>>
>>> +ret = of_property_read_u32(np, "input-debounce",
>>> + >debounce_usecs);
>>> +if (ret)
>>> +info->debounce_usecs = USB_GPIO_DEBOUNCE_MS;
>>
>> The USB_GPIO_DEBOUNCE_MS indicates 20 millisecond.
>> You need to redefine it as following:
>>   -#define USB_GPIO_DEBOUNCE_MS   20  /* ms */
>>   +#define USB_GPIO_DEBOUNCE_USEC 2
>>
>>   info->debounce_usecs = USB_GPIO_DEBOUNCE_USEC;
>>
>> or
>>   info->debounce_usecs = USB_GPIO_DEBOUNCE_MS * 1000;
>>
>>
>>> +
>>>  info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable);
>>>  if (IS_ERR(info->edev)) {
>>>  dev_err(dev, "failed to allocate extcon device\n");
>>> @@ -147,13 +153,13 @@ static int usb_extcon_probe(struct platform_device 
>>> *pdev)
>>>
>>>  if (info->id_gpiod)
>>>  ret = gpiod_set_debounce(info->id_gpiod,
>>> - USB_GPIO_DEBOUNCE_MS * 1000);
>>> + info->debounce_usecs * 1000);
>>
>> The debounce_usecs is already microsecond, You don't need to mutiply with 
>> 1000.
>>
>>
>>>  if (!ret && info->vbus_gpiod)
>>>  ret = gpiod_set_debounce(info->vbus_gpiod,
>>> - USB_GPIO_DEBOUNCE_MS * 1000);
>>> + info->debounce_usecs * 1000);
>
> You don't need to mutiply with 1000.
>
>>>
>>>  if (ret < 0)
>>> -info->debounce_jiffies = 
>>> msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS);
>>> +info->debounce_jiffies = 
>>> msecs_to_jiffies(info->debounce_usecs);
>
> You should you the 'usecs_to_jiffies' because info->debounce_usecs indicates 
> the usec.
>
> --
> Best Regards,
> Chanwoo Choi
> Samsung Electronics


[PATCH v2 2/2] extcon: add optional debounce-timeout-ms attribute

2017-10-18 Thread Raveendra Padasalagi
Add changes to capture optional dt attribute "debounce-timeout-ms"
provided in extcon node and used the same value if provided otherwise
default value of 20ms is used for id and vbus gpios debounce time.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Srinath Mannam <srinath.man...@broadcom.com>
---

Changes in v2:
 Rename gpio_debounce_timeout_ms to debounce_usecs

 drivers/extcon/extcon-usb-gpio.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index 9c925b0..76ef1da 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -41,6 +41,7 @@ struct usb_extcon_info {
 
unsigned long debounce_jiffies;
struct delayed_work wq_detcable;
+   unsigned int debounce_usecs;
 };
 
 static const unsigned int usb_extcon_cable[] = {
@@ -133,6 +134,11 @@ static int usb_extcon_probe(struct platform_device *pdev)
if (IS_ERR(info->vbus_gpiod))
return PTR_ERR(info->vbus_gpiod);
 
+   ret = of_property_read_u32(np, "input-debounce",
+>debounce_usecs);
+   if (ret)
+   info->debounce_usecs = USB_GPIO_DEBOUNCE_MS;
+
info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable);
if (IS_ERR(info->edev)) {
dev_err(dev, "failed to allocate extcon device\n");
@@ -147,13 +153,13 @@ static int usb_extcon_probe(struct platform_device *pdev)
 
if (info->id_gpiod)
ret = gpiod_set_debounce(info->id_gpiod,
-USB_GPIO_DEBOUNCE_MS * 1000);
+info->debounce_usecs * 1000);
if (!ret && info->vbus_gpiod)
ret = gpiod_set_debounce(info->vbus_gpiod,
-USB_GPIO_DEBOUNCE_MS * 1000);
+info->debounce_usecs * 1000);
 
if (ret < 0)
-   info->debounce_jiffies = msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS);
+   info->debounce_jiffies = msecs_to_jiffies(info->debounce_usecs);
 
INIT_DELAYED_WORK(>wq_detcable, usb_extcon_detect_cable);
 
-- 
1.9.1



[PATCH v2 2/2] extcon: add optional debounce-timeout-ms attribute

2017-10-18 Thread Raveendra Padasalagi
Add changes to capture optional dt attribute "debounce-timeout-ms"
provided in extcon node and used the same value if provided otherwise
default value of 20ms is used for id and vbus gpios debounce time.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Srinath Mannam 
---

Changes in v2:
 Rename gpio_debounce_timeout_ms to debounce_usecs

 drivers/extcon/extcon-usb-gpio.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index 9c925b0..76ef1da 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -41,6 +41,7 @@ struct usb_extcon_info {
 
unsigned long debounce_jiffies;
struct delayed_work wq_detcable;
+   unsigned int debounce_usecs;
 };
 
 static const unsigned int usb_extcon_cable[] = {
@@ -133,6 +134,11 @@ static int usb_extcon_probe(struct platform_device *pdev)
if (IS_ERR(info->vbus_gpiod))
return PTR_ERR(info->vbus_gpiod);
 
+   ret = of_property_read_u32(np, "input-debounce",
+>debounce_usecs);
+   if (ret)
+   info->debounce_usecs = USB_GPIO_DEBOUNCE_MS;
+
info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable);
if (IS_ERR(info->edev)) {
dev_err(dev, "failed to allocate extcon device\n");
@@ -147,13 +153,13 @@ static int usb_extcon_probe(struct platform_device *pdev)
 
if (info->id_gpiod)
ret = gpiod_set_debounce(info->id_gpiod,
-USB_GPIO_DEBOUNCE_MS * 1000);
+info->debounce_usecs * 1000);
if (!ret && info->vbus_gpiod)
ret = gpiod_set_debounce(info->vbus_gpiod,
-USB_GPIO_DEBOUNCE_MS * 1000);
+info->debounce_usecs * 1000);
 
if (ret < 0)
-   info->debounce_jiffies = msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS);
+   info->debounce_jiffies = msecs_to_jiffies(info->debounce_usecs);
 
INIT_DELAYED_WORK(>wq_detcable, usb_extcon_detect_cable);
 
-- 
1.9.1



[PATCH v2 1/2] Documentation: dt: extcon: add optional debounce-timeout-ms attribute

2017-10-18 Thread Raveendra Padasalagi
Add documentation on optional dt attribute "debounce-timeout-ms"
in extcon node to capture user specified timeout value for id
and vbus gpio detection.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Srinath Mannam <srinath.man...@broadcom.com>
---

Changes in v2:
 Rename debounce-timeout-ms to input-debounce

 Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt 
b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
index dfc14f7..d115900 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
@@ -10,6 +10,9 @@ Either one of id-gpio or vbus-gpio must be present. Both can 
be present as well.
 - id-gpio: gpio for USB ID pin. See gpio binding.
 - vbus-gpio: gpio for USB VBUS pin.
 
+Optional properties:
+- input-debounce: debounce timeout value for id and vbus gpio in microseconds.
+
 Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
extcon_usb1 {
compatible = "linux,extcon-usb-gpio";
-- 
1.9.1



[PATCH v2 1/2] Documentation: dt: extcon: add optional debounce-timeout-ms attribute

2017-10-18 Thread Raveendra Padasalagi
Add documentation on optional dt attribute "debounce-timeout-ms"
in extcon node to capture user specified timeout value for id
and vbus gpio detection.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Srinath Mannam 
---

Changes in v2:
 Rename debounce-timeout-ms to input-debounce

 Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt 
b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
index dfc14f7..d115900 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
@@ -10,6 +10,9 @@ Either one of id-gpio or vbus-gpio must be present. Both can 
be present as well.
 - id-gpio: gpio for USB ID pin. See gpio binding.
 - vbus-gpio: gpio for USB VBUS pin.
 
+Optional properties:
+- input-debounce: debounce timeout value for id and vbus gpio in microseconds.
+
 Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
extcon_usb1 {
compatible = "linux,extcon-usb-gpio";
-- 
1.9.1



[PATCH 1/2] Documentation: dt: extcon: add optional debounce-timeout-ms attribute

2017-10-16 Thread Raveendra Padasalagi
Add documentation on optional dt attribute "debounce-timeout-ms"
in extcon node to capture user specified timeout value for id
and vbus gpio detection.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Srinath Mannam <srinath.man...@broadcom.com>
---
 Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt 
b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
index dfc14f7..6df6d69 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
@@ -10,6 +10,10 @@ Either one of id-gpio or vbus-gpio must be present. Both can 
be present as well.
 - id-gpio: gpio for USB ID pin. See gpio binding.
 - vbus-gpio: gpio for USB VBUS pin.
 
+Optional properties:
+- debounce-timeout-ms: debounce timeout value for id and vbus gpio in
+  milliseconds.
+
 Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
extcon_usb1 {
compatible = "linux,extcon-usb-gpio";
-- 
1.9.1



[PATCH 2/2] extcon: add optional debounce-timeout-ms attribute

2017-10-16 Thread Raveendra Padasalagi
Add changes to capture optional dt attribute "debounce-timeout-ms"
provided in extcon node and used the same value if provided otherwise
default value of 20ms is used for id and vbus gpios debounce time.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Srinath Mannam <srinath.man...@broadcom.com>
---
 drivers/extcon/extcon-usb-gpio.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index 9c925b0..090f65f 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -41,6 +41,7 @@ struct usb_extcon_info {
 
unsigned long debounce_jiffies;
struct delayed_work wq_detcable;
+   unsigned int gpio_debounce_timeout_ms;
 };
 
 static const unsigned int usb_extcon_cable[] = {
@@ -133,6 +134,11 @@ static int usb_extcon_probe(struct platform_device *pdev)
if (IS_ERR(info->vbus_gpiod))
return PTR_ERR(info->vbus_gpiod);
 
+   ret = of_property_read_u32(np, "debounce-timeout-ms",
+>gpio_debounce_timeout_ms);
+   if (ret)
+   info->gpio_debounce_timeout_ms = USB_GPIO_DEBOUNCE_MS;
+
info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable);
if (IS_ERR(info->edev)) {
dev_err(dev, "failed to allocate extcon device\n");
@@ -147,13 +153,14 @@ static int usb_extcon_probe(struct platform_device *pdev)
 
if (info->id_gpiod)
ret = gpiod_set_debounce(info->id_gpiod,
-USB_GPIO_DEBOUNCE_MS * 1000);
+info->gpio_debounce_timeout_ms * 1000);
if (!ret && info->vbus_gpiod)
ret = gpiod_set_debounce(info->vbus_gpiod,
-USB_GPIO_DEBOUNCE_MS * 1000);
+info->gpio_debounce_timeout_ms * 1000);
 
if (ret < 0)
-   info->debounce_jiffies = msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS);
+   info->debounce_jiffies = msecs_to_jiffies(
+   info->gpio_debounce_timeout_ms);
 
INIT_DELAYED_WORK(>wq_detcable, usb_extcon_detect_cable);
 
-- 
1.9.1



[PATCH 1/2] Documentation: dt: extcon: add optional debounce-timeout-ms attribute

2017-10-16 Thread Raveendra Padasalagi
Add documentation on optional dt attribute "debounce-timeout-ms"
in extcon node to capture user specified timeout value for id
and vbus gpio detection.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Srinath Mannam 
---
 Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt 
b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
index dfc14f7..6df6d69 100644
--- a/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
+++ b/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
@@ -10,6 +10,10 @@ Either one of id-gpio or vbus-gpio must be present. Both can 
be present as well.
 - id-gpio: gpio for USB ID pin. See gpio binding.
 - vbus-gpio: gpio for USB VBUS pin.
 
+Optional properties:
+- debounce-timeout-ms: debounce timeout value for id and vbus gpio in
+  milliseconds.
+
 Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
extcon_usb1 {
compatible = "linux,extcon-usb-gpio";
-- 
1.9.1



[PATCH 2/2] extcon: add optional debounce-timeout-ms attribute

2017-10-16 Thread Raveendra Padasalagi
Add changes to capture optional dt attribute "debounce-timeout-ms"
provided in extcon node and used the same value if provided otherwise
default value of 20ms is used for id and vbus gpios debounce time.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Srinath Mannam 
---
 drivers/extcon/extcon-usb-gpio.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index 9c925b0..090f65f 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -41,6 +41,7 @@ struct usb_extcon_info {
 
unsigned long debounce_jiffies;
struct delayed_work wq_detcable;
+   unsigned int gpio_debounce_timeout_ms;
 };
 
 static const unsigned int usb_extcon_cable[] = {
@@ -133,6 +134,11 @@ static int usb_extcon_probe(struct platform_device *pdev)
if (IS_ERR(info->vbus_gpiod))
return PTR_ERR(info->vbus_gpiod);
 
+   ret = of_property_read_u32(np, "debounce-timeout-ms",
+>gpio_debounce_timeout_ms);
+   if (ret)
+   info->gpio_debounce_timeout_ms = USB_GPIO_DEBOUNCE_MS;
+
info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable);
if (IS_ERR(info->edev)) {
dev_err(dev, "failed to allocate extcon device\n");
@@ -147,13 +153,14 @@ static int usb_extcon_probe(struct platform_device *pdev)
 
if (info->id_gpiod)
ret = gpiod_set_debounce(info->id_gpiod,
-USB_GPIO_DEBOUNCE_MS * 1000);
+info->gpio_debounce_timeout_ms * 1000);
if (!ret && info->vbus_gpiod)
ret = gpiod_set_debounce(info->vbus_gpiod,
-USB_GPIO_DEBOUNCE_MS * 1000);
+info->gpio_debounce_timeout_ms * 1000);
 
if (ret < 0)
-   info->debounce_jiffies = msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS);
+   info->debounce_jiffies = msecs_to_jiffies(
+   info->gpio_debounce_timeout_ms);
 
INIT_DELAYED_WORK(>wq_detcable, usb_extcon_detect_cable);
 
-- 
1.9.1



[PATCH] crypto: brcm - Explicity ACK mailbox message

2017-08-29 Thread Raveendra Padasalagi
Add support to explicity ACK mailbox message
because after sending message we can know
the send status via error attribute of brcm_message.

This is needed to support "txdone_ack" supported in
mailbox controller driver.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Anup Patel <anup.pa...@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
Cc: sta...@vger.kernel.org

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index 9cfd36c..45440ac 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -258,6 +258,44 @@ static u8 select_channel(void)
return 0;
 }
 
+static int mailbox_send_message(struct brcm_message *mssg, u32 flags,
+   u8 chan_idx)
+{
+   int err;
+   int retry_cnt = 0;
+   struct device *dev = &(iproc_priv.pdev->dev);
+
+   err = mbox_send_message(iproc_priv.mbox[chan_idx], mssg);
+   if (flags & CRYPTO_TFM_REQ_MAY_SLEEP) {
+   while ((err == -ENOBUFS) && (retry_cnt < SPU_MB_RETRY_MAX)) {
+   /*
+* Mailbox queue is full. Since MAY_SLEEP is set, assume
+* not in atomic context and we can wait and try again.
+*/
+   retry_cnt++;
+   usleep_range(MBOX_SLEEP_MIN, MBOX_SLEEP_MAX);
+   err = mbox_send_message(iproc_priv.mbox[chan_idx],
+   mssg);
+   atomic_inc(_priv.mb_no_spc);
+   }
+   }
+   if (err < 0) {
+   atomic_inc(_priv.mb_send_fail);
+   return err;
+   }
+
+   /* Check error returned by mailbox controller */
+   err = mssg->error;
+   if (unlikely(err < 0)) {
+   dev_err(dev, "message error %d", err);
+   /* Signal txdone for mailbox channel */
+   }
+
+   /* Signal txdone for mailbox channel */
+   mbox_client_txdone(iproc_priv.mbox[chan_idx], err);
+   return err;
+}
+
 /**
  * handle_ablkcipher_req() - Submit as much of a block cipher request as fits 
in
  * a single SPU request message, starting at the current position in the 
request
@@ -295,7 +333,6 @@ static int handle_ablkcipher_req(struct iproc_reqctx_s 
*rctx)
u32 pad_len;/* total length of all padding */
bool update_key = false;
struct brcm_message *mssg;  /* mailbox message */
-   int retry_cnt = 0;
 
/* number of entries in src and dst sg in mailbox message. */
u8 rx_frag_num = 2; /* response header and STATUS */
@@ -464,24 +501,9 @@ static int handle_ablkcipher_req(struct iproc_reqctx_s 
*rctx)
if (err)
return err;
 
-   err = mbox_send_message(iproc_priv.mbox[rctx->chan_idx], mssg);
-   if (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) {
-   while ((err == -ENOBUFS) && (retry_cnt < SPU_MB_RETRY_MAX)) {
-   /*
-* Mailbox queue is full. Since MAY_SLEEP is set, assume
-* not in atomic context and we can wait and try again.
-*/
-   retry_cnt++;
-   usleep_range(MBOX_SLEEP_MIN, MBOX_SLEEP_MAX);
-   err = mbox_send_message(iproc_priv.mbox[rctx->chan_idx],
-   mssg);
-   atomic_inc(_priv.mb_no_spc);
-   }
-   }
-   if (unlikely(err < 0)) {
-   atomic_inc(_priv.mb_send_fail);
+   err = mailbox_send_message(mssg, req->base.flags, rctx->chan_idx);
+   if (unlikely(err < 0))
return err;
-   }
 
return -EINPROGRESS;
 }
@@ -712,7 +734,6 @@ static int handle_ahash_req(struct iproc_reqctx_s *rctx)
u32 spu_hdr_len;
unsigned int digestsize;
u16 rem = 0;
-   int retry_cnt = 0;
 
/*
 * number of entries in src and dst sg. Always includes SPU msg header.
@@ -906,24 +927,10 @@ static int handle_ahash_req(struct iproc_reqctx_s *rctx)
if (err)
return err;
 
-   err = mbox_send_message(iproc_priv.mbox[rctx->chan_idx], mssg);
-   if (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) {
-   while ((err == -ENOBUFS) && (retry_cnt < SPU_MB_RETRY_MAX)) {
-   /*
-* Mailbox queue is full. Since MAY_SLEEP is set, assume
-* not in atomic context and we can wait and try again.
-*/
-   retry_cnt++;
-   usleep_range(MBOX_SLEEP_MIN, MBOX_SLEEP_MAX);
-   err = mbox

[PATCH] crypto: brcm - Explicity ACK mailbox message

2017-08-29 Thread Raveendra Padasalagi
Add support to explicity ACK mailbox message
because after sending message we can know
the send status via error attribute of brcm_message.

This is needed to support "txdone_ack" supported in
mailbox controller driver.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Anup Patel 
Reviewed-by: Scott Branden 
Cc: sta...@vger.kernel.org

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index 9cfd36c..45440ac 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -258,6 +258,44 @@ static u8 select_channel(void)
return 0;
 }
 
+static int mailbox_send_message(struct brcm_message *mssg, u32 flags,
+   u8 chan_idx)
+{
+   int err;
+   int retry_cnt = 0;
+   struct device *dev = &(iproc_priv.pdev->dev);
+
+   err = mbox_send_message(iproc_priv.mbox[chan_idx], mssg);
+   if (flags & CRYPTO_TFM_REQ_MAY_SLEEP) {
+   while ((err == -ENOBUFS) && (retry_cnt < SPU_MB_RETRY_MAX)) {
+   /*
+* Mailbox queue is full. Since MAY_SLEEP is set, assume
+* not in atomic context and we can wait and try again.
+*/
+   retry_cnt++;
+   usleep_range(MBOX_SLEEP_MIN, MBOX_SLEEP_MAX);
+   err = mbox_send_message(iproc_priv.mbox[chan_idx],
+   mssg);
+   atomic_inc(_priv.mb_no_spc);
+   }
+   }
+   if (err < 0) {
+   atomic_inc(_priv.mb_send_fail);
+   return err;
+   }
+
+   /* Check error returned by mailbox controller */
+   err = mssg->error;
+   if (unlikely(err < 0)) {
+   dev_err(dev, "message error %d", err);
+   /* Signal txdone for mailbox channel */
+   }
+
+   /* Signal txdone for mailbox channel */
+   mbox_client_txdone(iproc_priv.mbox[chan_idx], err);
+   return err;
+}
+
 /**
  * handle_ablkcipher_req() - Submit as much of a block cipher request as fits 
in
  * a single SPU request message, starting at the current position in the 
request
@@ -295,7 +333,6 @@ static int handle_ablkcipher_req(struct iproc_reqctx_s 
*rctx)
u32 pad_len;/* total length of all padding */
bool update_key = false;
struct brcm_message *mssg;  /* mailbox message */
-   int retry_cnt = 0;
 
/* number of entries in src and dst sg in mailbox message. */
u8 rx_frag_num = 2; /* response header and STATUS */
@@ -464,24 +501,9 @@ static int handle_ablkcipher_req(struct iproc_reqctx_s 
*rctx)
if (err)
return err;
 
-   err = mbox_send_message(iproc_priv.mbox[rctx->chan_idx], mssg);
-   if (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) {
-   while ((err == -ENOBUFS) && (retry_cnt < SPU_MB_RETRY_MAX)) {
-   /*
-* Mailbox queue is full. Since MAY_SLEEP is set, assume
-* not in atomic context and we can wait and try again.
-*/
-   retry_cnt++;
-   usleep_range(MBOX_SLEEP_MIN, MBOX_SLEEP_MAX);
-   err = mbox_send_message(iproc_priv.mbox[rctx->chan_idx],
-   mssg);
-   atomic_inc(_priv.mb_no_spc);
-   }
-   }
-   if (unlikely(err < 0)) {
-   atomic_inc(_priv.mb_send_fail);
+   err = mailbox_send_message(mssg, req->base.flags, rctx->chan_idx);
+   if (unlikely(err < 0))
return err;
-   }
 
return -EINPROGRESS;
 }
@@ -712,7 +734,6 @@ static int handle_ahash_req(struct iproc_reqctx_s *rctx)
u32 spu_hdr_len;
unsigned int digestsize;
u16 rem = 0;
-   int retry_cnt = 0;
 
/*
 * number of entries in src and dst sg. Always includes SPU msg header.
@@ -906,24 +927,10 @@ static int handle_ahash_req(struct iproc_reqctx_s *rctx)
if (err)
return err;
 
-   err = mbox_send_message(iproc_priv.mbox[rctx->chan_idx], mssg);
-   if (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) {
-   while ((err == -ENOBUFS) && (retry_cnt < SPU_MB_RETRY_MAX)) {
-   /*
-* Mailbox queue is full. Since MAY_SLEEP is set, assume
-* not in atomic context and we can wait and try again.
-*/
-   retry_cnt++;
-   usleep_range(MBOX_SLEEP_MIN, MBOX_SLEEP_MAX);
-   err = mbox_send_message(iproc_priv.mbox[rctx->chan_idx],
-   mssg);
-

[PATCH v1] crypto: brcm - Support more FlexRM rings than SPU engines.

2017-07-20 Thread Raveendra Padasalagi
Enhance code to generically support cases where DMA rings
are greater than or equal to number of SPU engines.
New hardware has underlying DMA engine-FlexRM with 32 rings
which can be used to communicate to any of the available
10 SPU engines.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
Reviewed-by: Florian Fainelli <f.faine...@gmail.com>
Cc: sta...@vger.kernel.org
---

Changes in v1:
  - Added error path to clean up mbox channel in spu_mb_init() in case
mbox channel request fails.
  - Removed spu_reg_vbase[] and used spu->reg_vbase[] array to store
mapped registers.
  - spu_dt_read() modified to improve readability

 drivers/crypto/bcm/cipher.c | 109 
 drivers/crypto/bcm/cipher.h |  13 +++---
 2 files changed, 56 insertions(+), 66 deletions(-)

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index cc0d5b9..875b507 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -89,8 +89,6 @@
 module_param(aead_pri, int, 0644);
 MODULE_PARM_DESC(aead_pri, "Priority for AEAD algos");
 
-#define MAX_SPUS 16
-
 /* A type 3 BCM header, expected to precede the SPU header for SPU-M.
  * Bits 3 and 4 in the first byte encode the channel number (the dma ringset).
  * 0x60 - ring 0
@@ -119,7 +117,7 @@ static u8 select_channel(void)
 {
u8 chan_idx = atomic_inc_return(_priv.next_chan);
 
-   return chan_idx % iproc_priv.spu.num_spu;
+   return chan_idx % iproc_priv.spu.num_chan;
 }
 
 /**
@@ -4527,8 +4525,13 @@ static void spu_functions_register(struct device *dev,
  */
 static int spu_mb_init(struct device *dev)
 {
-   struct mbox_client *mcl = _priv.mcl[iproc_priv.spu.num_spu];
-   int err;
+   struct mbox_client *mcl = _priv.mcl;
+   int err, i;
+
+   iproc_priv.mbox = devm_kcalloc(dev, iproc_priv.spu.num_chan,
+ sizeof(struct mbox_chan *), GFP_KERNEL);
+   if (!iproc_priv.mbox)
+   return -ENOMEM;
 
mcl->dev = dev;
mcl->tx_block = false;
@@ -4537,25 +4540,33 @@ static int spu_mb_init(struct device *dev)
mcl->rx_callback = spu_rx_callback;
mcl->tx_done = NULL;
 
-   iproc_priv.mbox[iproc_priv.spu.num_spu] =
-   mbox_request_channel(mcl, 0);
-   if (IS_ERR(iproc_priv.mbox[iproc_priv.spu.num_spu])) {
-   err = (int)PTR_ERR(iproc_priv.mbox[iproc_priv.spu.num_spu]);
-   dev_err(dev,
-   "Mbox channel %d request failed with err %d",
-   iproc_priv.spu.num_spu, err);
-   iproc_priv.mbox[iproc_priv.spu.num_spu] = NULL;
-   return err;
+   for (i = 0; i < iproc_priv.spu.num_chan; i++) {
+   iproc_priv.mbox[i] = mbox_request_channel(mcl, i);
+   if (IS_ERR(iproc_priv.mbox[i])) {
+   err = (int)PTR_ERR(iproc_priv.mbox[i]);
+   dev_err(dev,
+   "Mbox channel %d request failed with err %d",
+   i, err);
+   iproc_priv.mbox[i] = NULL;
+   goto free_channels;
+   }
}
 
return 0;
+free_channels:
+   for (i = 0; i < iproc_priv.spu.num_chan; i++) {
+   if (iproc_priv.mbox[i])
+   mbox_free_channel(iproc_priv.mbox[i]);
+   }
+
+   return err;
 }
 
 static void spu_mb_release(struct platform_device *pdev)
 {
int i;
 
-   for (i = 0; i < iproc_priv.spu.num_spu; i++)
+   for (i = 0; i < iproc_priv.spu.num_chan; i++)
mbox_free_channel(iproc_priv.mbox[i]);
 }
 
@@ -4566,7 +4577,7 @@ static void spu_counters_init(void)
 
atomic_set(_priv.session_count, 0);
atomic_set(_priv.stream_count, 0);
-   atomic_set(_priv.next_chan, (int)iproc_priv.spu.num_spu);
+   atomic_set(_priv.next_chan, (int)iproc_priv.spu.num_chan);
atomic64_set(_priv.bytes_in, 0);
atomic64_set(_priv.bytes_out, 0);
for (i = 0; i < SPU_OP_NUM; i++) {
@@ -4808,47 +4819,33 @@ static int spu_dt_read(struct platform_device *pdev)
struct resource *spu_ctrl_regs;
const struct of_device_id *match;
const struct spu_type_subtype *matched_spu_type;
-   void __iomem *spu_reg_vbase[MAX_SPUS];
-   int err;
+   struct device_node *dn = pdev->dev.of_node;
+   int err, i;
+
+   /* Count number of mailbox channels */
+   spu->num_chan = of_count_phandle_with_args(dn, "mboxes", "#mbox-cells");
 
match = of_match_device(of_match_ptr(bcm_spu_dt_ids), dev);
matched_spu_type = match->data;
 
-   if (iproc_priv.spu.num_spu > 1) {
- 

[PATCH v1] crypto: brcm - Support more FlexRM rings than SPU engines.

2017-07-20 Thread Raveendra Padasalagi
Enhance code to generically support cases where DMA rings
are greater than or equal to number of SPU engines.
New hardware has underlying DMA engine-FlexRM with 32 rings
which can be used to communicate to any of the available
10 SPU engines.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Scott Branden 
Reviewed-by: Florian Fainelli 
Cc: sta...@vger.kernel.org
---

Changes in v1:
  - Added error path to clean up mbox channel in spu_mb_init() in case
mbox channel request fails.
  - Removed spu_reg_vbase[] and used spu->reg_vbase[] array to store
mapped registers.
  - spu_dt_read() modified to improve readability

 drivers/crypto/bcm/cipher.c | 109 
 drivers/crypto/bcm/cipher.h |  13 +++---
 2 files changed, 56 insertions(+), 66 deletions(-)

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index cc0d5b9..875b507 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -89,8 +89,6 @@
 module_param(aead_pri, int, 0644);
 MODULE_PARM_DESC(aead_pri, "Priority for AEAD algos");
 
-#define MAX_SPUS 16
-
 /* A type 3 BCM header, expected to precede the SPU header for SPU-M.
  * Bits 3 and 4 in the first byte encode the channel number (the dma ringset).
  * 0x60 - ring 0
@@ -119,7 +117,7 @@ static u8 select_channel(void)
 {
u8 chan_idx = atomic_inc_return(_priv.next_chan);
 
-   return chan_idx % iproc_priv.spu.num_spu;
+   return chan_idx % iproc_priv.spu.num_chan;
 }
 
 /**
@@ -4527,8 +4525,13 @@ static void spu_functions_register(struct device *dev,
  */
 static int spu_mb_init(struct device *dev)
 {
-   struct mbox_client *mcl = _priv.mcl[iproc_priv.spu.num_spu];
-   int err;
+   struct mbox_client *mcl = _priv.mcl;
+   int err, i;
+
+   iproc_priv.mbox = devm_kcalloc(dev, iproc_priv.spu.num_chan,
+ sizeof(struct mbox_chan *), GFP_KERNEL);
+   if (!iproc_priv.mbox)
+   return -ENOMEM;
 
mcl->dev = dev;
mcl->tx_block = false;
@@ -4537,25 +4540,33 @@ static int spu_mb_init(struct device *dev)
mcl->rx_callback = spu_rx_callback;
mcl->tx_done = NULL;
 
-   iproc_priv.mbox[iproc_priv.spu.num_spu] =
-   mbox_request_channel(mcl, 0);
-   if (IS_ERR(iproc_priv.mbox[iproc_priv.spu.num_spu])) {
-   err = (int)PTR_ERR(iproc_priv.mbox[iproc_priv.spu.num_spu]);
-   dev_err(dev,
-   "Mbox channel %d request failed with err %d",
-   iproc_priv.spu.num_spu, err);
-   iproc_priv.mbox[iproc_priv.spu.num_spu] = NULL;
-   return err;
+   for (i = 0; i < iproc_priv.spu.num_chan; i++) {
+   iproc_priv.mbox[i] = mbox_request_channel(mcl, i);
+   if (IS_ERR(iproc_priv.mbox[i])) {
+   err = (int)PTR_ERR(iproc_priv.mbox[i]);
+   dev_err(dev,
+   "Mbox channel %d request failed with err %d",
+   i, err);
+   iproc_priv.mbox[i] = NULL;
+   goto free_channels;
+   }
}
 
return 0;
+free_channels:
+   for (i = 0; i < iproc_priv.spu.num_chan; i++) {
+   if (iproc_priv.mbox[i])
+   mbox_free_channel(iproc_priv.mbox[i]);
+   }
+
+   return err;
 }
 
 static void spu_mb_release(struct platform_device *pdev)
 {
int i;
 
-   for (i = 0; i < iproc_priv.spu.num_spu; i++)
+   for (i = 0; i < iproc_priv.spu.num_chan; i++)
mbox_free_channel(iproc_priv.mbox[i]);
 }
 
@@ -4566,7 +4577,7 @@ static void spu_counters_init(void)
 
atomic_set(_priv.session_count, 0);
atomic_set(_priv.stream_count, 0);
-   atomic_set(_priv.next_chan, (int)iproc_priv.spu.num_spu);
+   atomic_set(_priv.next_chan, (int)iproc_priv.spu.num_chan);
atomic64_set(_priv.bytes_in, 0);
atomic64_set(_priv.bytes_out, 0);
for (i = 0; i < SPU_OP_NUM; i++) {
@@ -4808,47 +4819,33 @@ static int spu_dt_read(struct platform_device *pdev)
struct resource *spu_ctrl_regs;
const struct of_device_id *match;
const struct spu_type_subtype *matched_spu_type;
-   void __iomem *spu_reg_vbase[MAX_SPUS];
-   int err;
+   struct device_node *dn = pdev->dev.of_node;
+   int err, i;
+
+   /* Count number of mailbox channels */
+   spu->num_chan = of_count_phandle_with_args(dn, "mboxes", "#mbox-cells");
 
match = of_match_device(of_match_ptr(bcm_spu_dt_ids), dev);
matched_spu_type = match->data;
 
-   if (iproc_priv.spu.num_spu > 1) {
-   /* If this is 2nd or later SPU, make sure it's same type */
-   if ((spu->

RE: [PATCH] crypto: brcm - Support more FlexRM rings than SPU engines.

2017-07-18 Thread Raveendra Padasalagi
Need to address few issues in the patch.
So NAKing this patch. Will send out re-vised version.

Regards,
Raveendra
> -Original Message-
> From: Raveendra Padasalagi [mailto:raveendra.padasal...@broadcom.com]
> Sent: 13 July 2017 13:58
> To: Herbert Xu; David S. Miller; Rob Rice; Scott Branden; linux-
> cry...@vger.kernel.org
> Cc: Ray Jui; Steve Lin; bcm-kernel-feedback-l...@broadcom.com; linux-
> ker...@vger.kernel.org; Raveendra Padasalagi; sta...@vger.kernel.org
> Subject: [PATCH] crypto: brcm - Support more FlexRM rings than SPU
engines.
>
> Enhance code to generically support cases where DMA rings are greater
than or
> equal to number of SPU engines.
> New hardware has underlying DMA engine-FlexRM with 32 rings which can be
> used to communicate to any of the available
> 10 SPU engines.
>
> Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
> cc: sta...@vger.kernel.org
> ---
>  drivers/crypto/bcm/cipher.c | 105
+---
>  drivers/crypto/bcm/cipher.h |  15 ---
>  2 files changed, 57 insertions(+), 63 deletions(-)
>
> diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index
> cc0d5b9..ecc32d8 100644
> --- a/drivers/crypto/bcm/cipher.c
> +++ b/drivers/crypto/bcm/cipher.c
> @@ -119,7 +119,7 @@ static u8 select_channel(void)  {
>   u8 chan_idx = atomic_inc_return(_priv.next_chan);
>
> - return chan_idx % iproc_priv.spu.num_spu;
> + return chan_idx % iproc_priv.spu.num_chan;
>  }
>
>  /**
> @@ -4527,8 +4527,13 @@ static void spu_functions_register(struct device
> *dev,
>   */
>  static int spu_mb_init(struct device *dev)  {
> - struct mbox_client *mcl = _priv.mcl[iproc_priv.spu.num_spu];
> - int err;
> + struct mbox_client *mcl = _priv.mcl;
> + int err, i;
> +
> + iproc_priv.mbox = devm_kcalloc(dev, iproc_priv.spu.num_chan,
> +   sizeof(struct mbox_chan *), GFP_KERNEL);
> + if (iproc_priv.mbox == NULL)
> + return -ENOMEM;
>
>   mcl->dev = dev;
>   mcl->tx_block = false;
> @@ -4537,15 +4542,16 @@ static int spu_mb_init(struct device *dev)
>   mcl->rx_callback = spu_rx_callback;
>   mcl->tx_done = NULL;
>
> - iproc_priv.mbox[iproc_priv.spu.num_spu] =
> - mbox_request_channel(mcl, 0);
> - if (IS_ERR(iproc_priv.mbox[iproc_priv.spu.num_spu])) {
> - err =
(int)PTR_ERR(iproc_priv.mbox[iproc_priv.spu.num_spu]);
> - dev_err(dev,
> - "Mbox channel %d request failed with err %d",
> - iproc_priv.spu.num_spu, err);
> - iproc_priv.mbox[iproc_priv.spu.num_spu] = NULL;
> - return err;
> + for (i = 0; i < iproc_priv.spu.num_chan; i++) {
> + iproc_priv.mbox[i] = mbox_request_channel(mcl, i);
> + if (IS_ERR(iproc_priv.mbox[i])) {
> + err = (int)PTR_ERR(iproc_priv.mbox[i]);
> + dev_err(dev,
> + "Mbox channel %d request failed with err
%d",
> + i, err);
> + iproc_priv.mbox[i] = NULL;
> + return err;
> + }
>   }
>
>   return 0;
> @@ -4555,7 +4561,7 @@ static void spu_mb_release(struct platform_device
> *pdev)  {
>   int i;
>
> - for (i = 0; i < iproc_priv.spu.num_spu; i++)
> + for (i = 0; i < iproc_priv.spu.num_chan; i++)
>   mbox_free_channel(iproc_priv.mbox[i]);
>  }
>
> @@ -4566,7 +4572,7 @@ static void spu_counters_init(void)
>
>   atomic_set(_priv.session_count, 0);
>   atomic_set(_priv.stream_count, 0);
> - atomic_set(_priv.next_chan, (int)iproc_priv.spu.num_spu);
> + atomic_set(_priv.next_chan, (int)iproc_priv.spu.num_chan);
>   atomic64_set(_priv.bytes_in, 0);
>   atomic64_set(_priv.bytes_out, 0);
>   for (i = 0; i < SPU_OP_NUM; i++) {
> @@ -4809,46 +4815,41 @@ static int spu_dt_read(struct platform_device
> *pdev)
>   const struct of_device_id *match;
>   const struct spu_type_subtype *matched_spu_type;
>   void __iomem *spu_reg_vbase[MAX_SPUS];
> - int err;
> + struct device_node *dn = pdev->dev.of_node;
> + int err, i;
> +
> + /* Count number of mailbox channels */
> + spu->num_chan = of_count_phandle_with_args(dn, "mboxes",
> +"#mbox-cells");
>
>   match = of_match_device(of_match_ptr(bcm_spu_dt_ids), dev);
>   matched_spu_type = match->data;
>
> - if 

RE: [PATCH] crypto: brcm - Support more FlexRM rings than SPU engines.

2017-07-18 Thread Raveendra Padasalagi
Need to address few issues in the patch.
So NAKing this patch. Will send out re-vised version.

Regards,
Raveendra
> -Original Message-
> From: Raveendra Padasalagi [mailto:raveendra.padasal...@broadcom.com]
> Sent: 13 July 2017 13:58
> To: Herbert Xu; David S. Miller; Rob Rice; Scott Branden; linux-
> cry...@vger.kernel.org
> Cc: Ray Jui; Steve Lin; bcm-kernel-feedback-l...@broadcom.com; linux-
> ker...@vger.kernel.org; Raveendra Padasalagi; sta...@vger.kernel.org
> Subject: [PATCH] crypto: brcm - Support more FlexRM rings than SPU
engines.
>
> Enhance code to generically support cases where DMA rings are greater
than or
> equal to number of SPU engines.
> New hardware has underlying DMA engine-FlexRM with 32 rings which can be
> used to communicate to any of the available
> 10 SPU engines.
>
> Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
> Signed-off-by: Raveendra Padasalagi 
> cc: sta...@vger.kernel.org
> ---
>  drivers/crypto/bcm/cipher.c | 105
+---
>  drivers/crypto/bcm/cipher.h |  15 ---
>  2 files changed, 57 insertions(+), 63 deletions(-)
>
> diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index
> cc0d5b9..ecc32d8 100644
> --- a/drivers/crypto/bcm/cipher.c
> +++ b/drivers/crypto/bcm/cipher.c
> @@ -119,7 +119,7 @@ static u8 select_channel(void)  {
>   u8 chan_idx = atomic_inc_return(_priv.next_chan);
>
> - return chan_idx % iproc_priv.spu.num_spu;
> + return chan_idx % iproc_priv.spu.num_chan;
>  }
>
>  /**
> @@ -4527,8 +4527,13 @@ static void spu_functions_register(struct device
> *dev,
>   */
>  static int spu_mb_init(struct device *dev)  {
> - struct mbox_client *mcl = _priv.mcl[iproc_priv.spu.num_spu];
> - int err;
> + struct mbox_client *mcl = _priv.mcl;
> + int err, i;
> +
> + iproc_priv.mbox = devm_kcalloc(dev, iproc_priv.spu.num_chan,
> +   sizeof(struct mbox_chan *), GFP_KERNEL);
> + if (iproc_priv.mbox == NULL)
> + return -ENOMEM;
>
>   mcl->dev = dev;
>   mcl->tx_block = false;
> @@ -4537,15 +4542,16 @@ static int spu_mb_init(struct device *dev)
>   mcl->rx_callback = spu_rx_callback;
>   mcl->tx_done = NULL;
>
> - iproc_priv.mbox[iproc_priv.spu.num_spu] =
> - mbox_request_channel(mcl, 0);
> - if (IS_ERR(iproc_priv.mbox[iproc_priv.spu.num_spu])) {
> - err =
(int)PTR_ERR(iproc_priv.mbox[iproc_priv.spu.num_spu]);
> - dev_err(dev,
> - "Mbox channel %d request failed with err %d",
> - iproc_priv.spu.num_spu, err);
> - iproc_priv.mbox[iproc_priv.spu.num_spu] = NULL;
> - return err;
> + for (i = 0; i < iproc_priv.spu.num_chan; i++) {
> + iproc_priv.mbox[i] = mbox_request_channel(mcl, i);
> + if (IS_ERR(iproc_priv.mbox[i])) {
> + err = (int)PTR_ERR(iproc_priv.mbox[i]);
> + dev_err(dev,
> + "Mbox channel %d request failed with err
%d",
> + i, err);
> + iproc_priv.mbox[i] = NULL;
> + return err;
> + }
>   }
>
>   return 0;
> @@ -4555,7 +4561,7 @@ static void spu_mb_release(struct platform_device
> *pdev)  {
>   int i;
>
> - for (i = 0; i < iproc_priv.spu.num_spu; i++)
> + for (i = 0; i < iproc_priv.spu.num_chan; i++)
>   mbox_free_channel(iproc_priv.mbox[i]);
>  }
>
> @@ -4566,7 +4572,7 @@ static void spu_counters_init(void)
>
>   atomic_set(_priv.session_count, 0);
>   atomic_set(_priv.stream_count, 0);
> - atomic_set(_priv.next_chan, (int)iproc_priv.spu.num_spu);
> + atomic_set(_priv.next_chan, (int)iproc_priv.spu.num_chan);
>   atomic64_set(_priv.bytes_in, 0);
>   atomic64_set(_priv.bytes_out, 0);
>   for (i = 0; i < SPU_OP_NUM; i++) {
> @@ -4809,46 +4815,41 @@ static int spu_dt_read(struct platform_device
> *pdev)
>   const struct of_device_id *match;
>   const struct spu_type_subtype *matched_spu_type;
>   void __iomem *spu_reg_vbase[MAX_SPUS];
> - int err;
> + struct device_node *dn = pdev->dev.of_node;
> + int err, i;
> +
> + /* Count number of mailbox channels */
> + spu->num_chan = of_count_phandle_with_args(dn, "mboxes",
> +"#mbox-cells");
>
>   match = of_match_device(of_match_ptr(bcm_spu_dt_ids), dev);
>   matched_spu_type = match->data;
>
> - if (iproc_priv.spu.num_spu > 1) {
> -

[PATCH] crypto: brcm - Support more FlexRM rings than SPU engines.

2017-07-13 Thread Raveendra Padasalagi
Enhance code to generically support cases where DMA rings
are greater than or equal to number of SPU engines.
New hardware has underlying DMA engine-FlexRM with 32 rings
which can be used to communicate to any of the available
10 SPU engines.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
cc: sta...@vger.kernel.org
---
 drivers/crypto/bcm/cipher.c | 105 +---
 drivers/crypto/bcm/cipher.h |  15 ---
 2 files changed, 57 insertions(+), 63 deletions(-)

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index cc0d5b9..ecc32d8 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -119,7 +119,7 @@ static u8 select_channel(void)
 {
u8 chan_idx = atomic_inc_return(_priv.next_chan);
 
-   return chan_idx % iproc_priv.spu.num_spu;
+   return chan_idx % iproc_priv.spu.num_chan;
 }
 
 /**
@@ -4527,8 +4527,13 @@ static void spu_functions_register(struct device *dev,
  */
 static int spu_mb_init(struct device *dev)
 {
-   struct mbox_client *mcl = _priv.mcl[iproc_priv.spu.num_spu];
-   int err;
+   struct mbox_client *mcl = _priv.mcl;
+   int err, i;
+
+   iproc_priv.mbox = devm_kcalloc(dev, iproc_priv.spu.num_chan,
+ sizeof(struct mbox_chan *), GFP_KERNEL);
+   if (iproc_priv.mbox == NULL)
+   return -ENOMEM;
 
mcl->dev = dev;
mcl->tx_block = false;
@@ -4537,15 +4542,16 @@ static int spu_mb_init(struct device *dev)
mcl->rx_callback = spu_rx_callback;
mcl->tx_done = NULL;
 
-   iproc_priv.mbox[iproc_priv.spu.num_spu] =
-   mbox_request_channel(mcl, 0);
-   if (IS_ERR(iproc_priv.mbox[iproc_priv.spu.num_spu])) {
-   err = (int)PTR_ERR(iproc_priv.mbox[iproc_priv.spu.num_spu]);
-   dev_err(dev,
-   "Mbox channel %d request failed with err %d",
-   iproc_priv.spu.num_spu, err);
-   iproc_priv.mbox[iproc_priv.spu.num_spu] = NULL;
-   return err;
+   for (i = 0; i < iproc_priv.spu.num_chan; i++) {
+   iproc_priv.mbox[i] = mbox_request_channel(mcl, i);
+   if (IS_ERR(iproc_priv.mbox[i])) {
+   err = (int)PTR_ERR(iproc_priv.mbox[i]);
+   dev_err(dev,
+   "Mbox channel %d request failed with err %d",
+   i, err);
+   iproc_priv.mbox[i] = NULL;
+   return err;
+   }
}
 
return 0;
@@ -4555,7 +4561,7 @@ static void spu_mb_release(struct platform_device *pdev)
 {
int i;
 
-   for (i = 0; i < iproc_priv.spu.num_spu; i++)
+   for (i = 0; i < iproc_priv.spu.num_chan; i++)
mbox_free_channel(iproc_priv.mbox[i]);
 }
 
@@ -4566,7 +4572,7 @@ static void spu_counters_init(void)
 
atomic_set(_priv.session_count, 0);
atomic_set(_priv.stream_count, 0);
-   atomic_set(_priv.next_chan, (int)iproc_priv.spu.num_spu);
+   atomic_set(_priv.next_chan, (int)iproc_priv.spu.num_chan);
atomic64_set(_priv.bytes_in, 0);
atomic64_set(_priv.bytes_out, 0);
for (i = 0; i < SPU_OP_NUM; i++) {
@@ -4809,46 +4815,41 @@ static int spu_dt_read(struct platform_device *pdev)
const struct of_device_id *match;
const struct spu_type_subtype *matched_spu_type;
void __iomem *spu_reg_vbase[MAX_SPUS];
-   int err;
+   struct device_node *dn = pdev->dev.of_node;
+   int err, i;
+
+   /* Count number of mailbox channels */
+   spu->num_chan = of_count_phandle_with_args(dn, "mboxes", "#mbox-cells");
 
match = of_match_device(of_match_ptr(bcm_spu_dt_ids), dev);
matched_spu_type = match->data;
 
-   if (iproc_priv.spu.num_spu > 1) {
-   /* If this is 2nd or later SPU, make sure it's same type */
-   if ((spu->spu_type != matched_spu_type->type) ||
-   (spu->spu_subtype != matched_spu_type->subtype)) {
-   err = -EINVAL;
-   dev_err(>dev, "Multiple SPU types not allowed");
-   return err;
-   }
-   } else {
-   /* Record type of first SPU */
-   spu->spu_type = matched_spu_type->type;
-   spu->spu_subtype = matched_spu_type->subtype;
-   }
+   spu->spu_type = matched_spu_type->type;
+   spu->spu_subtype = matched_spu_type->subtype;
 
-   /* Get and map SPU registers */
-   spu_ctrl_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!spu_ctrl_regs) {
-   err = -EINVAL;
-   dev_err(>de

[PATCH] crypto: brcm - Support more FlexRM rings than SPU engines.

2017-07-13 Thread Raveendra Padasalagi
Enhance code to generically support cases where DMA rings
are greater than or equal to number of SPU engines.
New hardware has underlying DMA engine-FlexRM with 32 rings
which can be used to communicate to any of the available
10 SPU engines.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Raveendra Padasalagi 
cc: sta...@vger.kernel.org
---
 drivers/crypto/bcm/cipher.c | 105 +---
 drivers/crypto/bcm/cipher.h |  15 ---
 2 files changed, 57 insertions(+), 63 deletions(-)

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index cc0d5b9..ecc32d8 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -119,7 +119,7 @@ static u8 select_channel(void)
 {
u8 chan_idx = atomic_inc_return(_priv.next_chan);
 
-   return chan_idx % iproc_priv.spu.num_spu;
+   return chan_idx % iproc_priv.spu.num_chan;
 }
 
 /**
@@ -4527,8 +4527,13 @@ static void spu_functions_register(struct device *dev,
  */
 static int spu_mb_init(struct device *dev)
 {
-   struct mbox_client *mcl = _priv.mcl[iproc_priv.spu.num_spu];
-   int err;
+   struct mbox_client *mcl = _priv.mcl;
+   int err, i;
+
+   iproc_priv.mbox = devm_kcalloc(dev, iproc_priv.spu.num_chan,
+ sizeof(struct mbox_chan *), GFP_KERNEL);
+   if (iproc_priv.mbox == NULL)
+   return -ENOMEM;
 
mcl->dev = dev;
mcl->tx_block = false;
@@ -4537,15 +4542,16 @@ static int spu_mb_init(struct device *dev)
mcl->rx_callback = spu_rx_callback;
mcl->tx_done = NULL;
 
-   iproc_priv.mbox[iproc_priv.spu.num_spu] =
-   mbox_request_channel(mcl, 0);
-   if (IS_ERR(iproc_priv.mbox[iproc_priv.spu.num_spu])) {
-   err = (int)PTR_ERR(iproc_priv.mbox[iproc_priv.spu.num_spu]);
-   dev_err(dev,
-   "Mbox channel %d request failed with err %d",
-   iproc_priv.spu.num_spu, err);
-   iproc_priv.mbox[iproc_priv.spu.num_spu] = NULL;
-   return err;
+   for (i = 0; i < iproc_priv.spu.num_chan; i++) {
+   iproc_priv.mbox[i] = mbox_request_channel(mcl, i);
+   if (IS_ERR(iproc_priv.mbox[i])) {
+   err = (int)PTR_ERR(iproc_priv.mbox[i]);
+   dev_err(dev,
+   "Mbox channel %d request failed with err %d",
+   i, err);
+   iproc_priv.mbox[i] = NULL;
+   return err;
+   }
}
 
return 0;
@@ -4555,7 +4561,7 @@ static void spu_mb_release(struct platform_device *pdev)
 {
int i;
 
-   for (i = 0; i < iproc_priv.spu.num_spu; i++)
+   for (i = 0; i < iproc_priv.spu.num_chan; i++)
mbox_free_channel(iproc_priv.mbox[i]);
 }
 
@@ -4566,7 +4572,7 @@ static void spu_counters_init(void)
 
atomic_set(_priv.session_count, 0);
atomic_set(_priv.stream_count, 0);
-   atomic_set(_priv.next_chan, (int)iproc_priv.spu.num_spu);
+   atomic_set(_priv.next_chan, (int)iproc_priv.spu.num_chan);
atomic64_set(_priv.bytes_in, 0);
atomic64_set(_priv.bytes_out, 0);
for (i = 0; i < SPU_OP_NUM; i++) {
@@ -4809,46 +4815,41 @@ static int spu_dt_read(struct platform_device *pdev)
const struct of_device_id *match;
const struct spu_type_subtype *matched_spu_type;
void __iomem *spu_reg_vbase[MAX_SPUS];
-   int err;
+   struct device_node *dn = pdev->dev.of_node;
+   int err, i;
+
+   /* Count number of mailbox channels */
+   spu->num_chan = of_count_phandle_with_args(dn, "mboxes", "#mbox-cells");
 
match = of_match_device(of_match_ptr(bcm_spu_dt_ids), dev);
matched_spu_type = match->data;
 
-   if (iproc_priv.spu.num_spu > 1) {
-   /* If this is 2nd or later SPU, make sure it's same type */
-   if ((spu->spu_type != matched_spu_type->type) ||
-   (spu->spu_subtype != matched_spu_type->subtype)) {
-   err = -EINVAL;
-   dev_err(>dev, "Multiple SPU types not allowed");
-   return err;
-   }
-   } else {
-   /* Record type of first SPU */
-   spu->spu_type = matched_spu_type->type;
-   spu->spu_subtype = matched_spu_type->subtype;
-   }
+   spu->spu_type = matched_spu_type->type;
+   spu->spu_subtype = matched_spu_type->subtype;
 
-   /* Get and map SPU registers */
-   spu_ctrl_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!spu_ctrl_regs) {
-   err = -EINVAL;
-   dev_err(>dev, "Invalid/missing registers for SPU\n")

[PATCH] crypto: brcm - remove BCM_PDC_MBOX dependency in Kconfig

2017-07-11 Thread Raveendra Padasalagi
SPU driver is dependent on generic MAILBOX API's to
communicate with underlying DMA engine driver.

So this patch removes BCM_PDC_MBOX "depends on" for SPU driver
in Kconfig and adds MAILBOX as dependent module.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
Cc: sta...@vger.kernel.org
---
 drivers/crypto/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index fb1e60f..778fc1b 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -629,7 +629,7 @@ source "drivers/crypto/virtio/Kconfig"
 config CRYPTO_DEV_BCM_SPU
tristate "Broadcom symmetric crypto/hash acceleration support"
depends on ARCH_BCM_IPROC
-   depends on BCM_PDC_MBOX
+   depends on MAILBOX
default m
select CRYPTO_DES
select CRYPTO_MD5
-- 
1.9.1



[PATCH] crypto: brcm - remove BCM_PDC_MBOX dependency in Kconfig

2017-07-11 Thread Raveendra Padasalagi
SPU driver is dependent on generic MAILBOX API's to
communicate with underlying DMA engine driver.

So this patch removes BCM_PDC_MBOX "depends on" for SPU driver
in Kconfig and adds MAILBOX as dependent module.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
Cc: sta...@vger.kernel.org
---
 drivers/crypto/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index fb1e60f..778fc1b 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -629,7 +629,7 @@ source "drivers/crypto/virtio/Kconfig"
 config CRYPTO_DEV_BCM_SPU
tristate "Broadcom symmetric crypto/hash acceleration support"
depends on ARCH_BCM_IPROC
-   depends on BCM_PDC_MBOX
+   depends on MAILBOX
default m
select CRYPTO_DES
select CRYPTO_MD5
-- 
1.9.1



Re: [PATCH v1] crypto: brcm - software fallback for cryptlen zero

2017-06-23 Thread Raveendra Padasalagi
Need to consider some more scenarios.
So NAKing this patch. Will send out re-vised version.

Regards,
Raveendra


On Fri, Jun 23, 2017 at 2:24 PM, Raveendra Padasalagi
<raveendra.padasal...@broadcom.com> wrote:
> Zero length payload requests are not handled in
> Broadcom SPU2 engine, so this patch adds conditional
> check to fallback to software implementation for AES-GCM
> and AES-CCM algorithms.
>
> Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
> Reviewed-by: Ray Jui <ray@broadcom.com>
> Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
> Cc: sta...@vger.kernel.org
> ---
>
> Changes in v1:
>  - Added Cc tag in the Signed-off area to send the patch to stable kernel
>
>  drivers/crypto/bcm/cipher.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
> index cc0d5b9..6c80863 100644
> --- a/drivers/crypto/bcm/cipher.c
> +++ b/drivers/crypto/bcm/cipher.c
> @@ -2625,7 +2625,7 @@ static int aead_need_fallback(struct aead_request *req)
>  */
> if (((ctx->cipher.mode == CIPHER_MODE_GCM) ||
>  (ctx->cipher.mode == CIPHER_MODE_CCM)) &&
> -   (req->assoclen == 0)) {
> +   ((req->assoclen == 0) || (req->cryptlen == 0))) {
> if ((rctx->is_encrypt && (req->cryptlen == 0)) ||
> (!rctx->is_encrypt && (req->cryptlen == 
> ctx->digestsize))) {
> flow_log("AES GCM/CCM needs fallback for 0 len 
> req\n");
> --
> 1.9.1
>


Re: [PATCH v1] crypto: brcm - software fallback for cryptlen zero

2017-06-23 Thread Raveendra Padasalagi
Need to consider some more scenarios.
So NAKing this patch. Will send out re-vised version.

Regards,
Raveendra


On Fri, Jun 23, 2017 at 2:24 PM, Raveendra Padasalagi
 wrote:
> Zero length payload requests are not handled in
> Broadcom SPU2 engine, so this patch adds conditional
> check to fallback to software implementation for AES-GCM
> and AES-CCM algorithms.
>
> Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
> Signed-off-by: Raveendra Padasalagi 
> Reviewed-by: Ray Jui 
> Reviewed-by: Scott Branden 
> Cc: sta...@vger.kernel.org
> ---
>
> Changes in v1:
>  - Added Cc tag in the Signed-off area to send the patch to stable kernel
>
>  drivers/crypto/bcm/cipher.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
> index cc0d5b9..6c80863 100644
> --- a/drivers/crypto/bcm/cipher.c
> +++ b/drivers/crypto/bcm/cipher.c
> @@ -2625,7 +2625,7 @@ static int aead_need_fallback(struct aead_request *req)
>  */
> if (((ctx->cipher.mode == CIPHER_MODE_GCM) ||
>  (ctx->cipher.mode == CIPHER_MODE_CCM)) &&
> -   (req->assoclen == 0)) {
> +   ((req->assoclen == 0) || (req->cryptlen == 0))) {
> if ((rctx->is_encrypt && (req->cryptlen == 0)) ||
> (!rctx->is_encrypt && (req->cryptlen == 
> ctx->digestsize))) {
> flow_log("AES GCM/CCM needs fallback for 0 len 
> req\n");
> --
> 1.9.1
>


[PATCH v1] crypto: brcm - Fix SHA3-512 algorithm failure

2017-06-23 Thread Raveendra Padasalagi
In Broadcom SPU driver, due to missing break statement
in spu2_hash_xlate() while mapping SPU2 equivalent
SHA3-512 value, -EINVAL is chosen and hence leading to
failure of SHA3-512 algorithm. This patch fixes the same.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
Cc: sta...@vger.kernel.org
---

Changes in v1:
 - Added Cc and fixes tag in the Signed-off area to send the patch
   to stable kernel

 drivers/crypto/bcm/spu2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/bcm/spu2.c b/drivers/crypto/bcm/spu2.c
index ef04c97..bf7ac62 100644
--- a/drivers/crypto/bcm/spu2.c
+++ b/drivers/crypto/bcm/spu2.c
@@ -302,6 +302,7 @@ static int spu2_hash_mode_xlate(enum hash_mode hash_mode,
break;
case HASH_ALG_SHA3_512:
*spu2_type = SPU2_HASH_TYPE_SHA3_512;
+   break;
case HASH_ALG_LAST:
default:
err = -EINVAL;
-- 
1.9.1



[PATCH v1] crypto: brcm - Fix SHA3-512 algorithm failure

2017-06-23 Thread Raveendra Padasalagi
In Broadcom SPU driver, due to missing break statement
in spu2_hash_xlate() while mapping SPU2 equivalent
SHA3-512 value, -EINVAL is chosen and hence leading to
failure of SHA3-512 algorithm. This patch fixes the same.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
Cc: sta...@vger.kernel.org
---

Changes in v1:
 - Added Cc and fixes tag in the Signed-off area to send the patch
   to stable kernel

 drivers/crypto/bcm/spu2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/bcm/spu2.c b/drivers/crypto/bcm/spu2.c
index ef04c97..bf7ac62 100644
--- a/drivers/crypto/bcm/spu2.c
+++ b/drivers/crypto/bcm/spu2.c
@@ -302,6 +302,7 @@ static int spu2_hash_mode_xlate(enum hash_mode hash_mode,
break;
case HASH_ALG_SHA3_512:
*spu2_type = SPU2_HASH_TYPE_SHA3_512;
+   break;
case HASH_ALG_LAST:
default:
err = -EINVAL;
-- 
1.9.1



[PATCH v1] crypto: brcm - software fallback for cryptlen zero

2017-06-23 Thread Raveendra Padasalagi
Zero length payload requests are not handled in
Broadcom SPU2 engine, so this patch adds conditional
check to fallback to software implementation for AES-GCM
and AES-CCM algorithms.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
Cc: sta...@vger.kernel.org
---

Changes in v1:
 - Added Cc tag in the Signed-off area to send the patch to stable kernel

 drivers/crypto/bcm/cipher.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index cc0d5b9..6c80863 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -2625,7 +2625,7 @@ static int aead_need_fallback(struct aead_request *req)
 */
if (((ctx->cipher.mode == CIPHER_MODE_GCM) ||
 (ctx->cipher.mode == CIPHER_MODE_CCM)) &&
-   (req->assoclen == 0)) {
+   ((req->assoclen == 0) || (req->cryptlen == 0))) {
if ((rctx->is_encrypt && (req->cryptlen == 0)) ||
(!rctx->is_encrypt && (req->cryptlen == ctx->digestsize))) {
flow_log("AES GCM/CCM needs fallback for 0 len req\n");
-- 
1.9.1



[PATCH v1] crypto: brcm - software fallback for cryptlen zero

2017-06-23 Thread Raveendra Padasalagi
Zero length payload requests are not handled in
Broadcom SPU2 engine, so this patch adds conditional
check to fallback to software implementation for AES-GCM
and AES-CCM algorithms.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
Cc: sta...@vger.kernel.org
---

Changes in v1:
 - Added Cc tag in the Signed-off area to send the patch to stable kernel

 drivers/crypto/bcm/cipher.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index cc0d5b9..6c80863 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -2625,7 +2625,7 @@ static int aead_need_fallback(struct aead_request *req)
 */
if (((ctx->cipher.mode == CIPHER_MODE_GCM) ||
 (ctx->cipher.mode == CIPHER_MODE_CCM)) &&
-   (req->assoclen == 0)) {
+   ((req->assoclen == 0) || (req->cryptlen == 0))) {
if ((rctx->is_encrypt && (req->cryptlen == 0)) ||
(!rctx->is_encrypt && (req->cryptlen == ctx->digestsize))) {
flow_log("AES GCM/CCM needs fallback for 0 len req\n");
-- 
1.9.1



[PATCH] crypto: brcm - software fallback for cryptlen zero

2017-06-23 Thread Raveendra Padasalagi
Zero length payload requests are not handled in
Broadcom SPU2 engine, so this patch adds conditional
check to fallback to software implementation for AES-GCM
and AES-CCM algorithms.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
---
 drivers/crypto/bcm/cipher.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index cc0d5b9..6c80863 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -2625,7 +2625,7 @@ static int aead_need_fallback(struct aead_request *req)
 */
if (((ctx->cipher.mode == CIPHER_MODE_GCM) ||
 (ctx->cipher.mode == CIPHER_MODE_CCM)) &&
-   (req->assoclen == 0)) {
+   ((req->assoclen == 0) || (req->cryptlen == 0))) {
if ((rctx->is_encrypt && (req->cryptlen == 0)) ||
(!rctx->is_encrypt && (req->cryptlen == ctx->digestsize))) {
flow_log("AES GCM/CCM needs fallback for 0 len req\n");
-- 
1.9.1



[PATCH] crypto: brcm - software fallback for cryptlen zero

2017-06-23 Thread Raveendra Padasalagi
Zero length payload requests are not handled in
Broadcom SPU2 engine, so this patch adds conditional
check to fallback to software implementation for AES-GCM
and AES-CCM algorithms.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 drivers/crypto/bcm/cipher.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index cc0d5b9..6c80863 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -2625,7 +2625,7 @@ static int aead_need_fallback(struct aead_request *req)
 */
if (((ctx->cipher.mode == CIPHER_MODE_GCM) ||
 (ctx->cipher.mode == CIPHER_MODE_CCM)) &&
-   (req->assoclen == 0)) {
+   ((req->assoclen == 0) || (req->cryptlen == 0))) {
if ((rctx->is_encrypt && (req->cryptlen == 0)) ||
(!rctx->is_encrypt && (req->cryptlen == ctx->digestsize))) {
flow_log("AES GCM/CCM needs fallback for 0 len req\n");
-- 
1.9.1



[PATCH] crypto: brcm - Fix SHA3-512 algorithm failure

2017-06-23 Thread Raveendra Padasalagi
In Broadcom SPU driver, due to missing break statement
in spu2_hash_xlate() while mapping SPU2 equivalent
SHA3-512 value, -EINVAL is chosen and hence leading to
failure of SHA3-512 algorithm. This patch fixes the same.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
---
 drivers/crypto/bcm/spu2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/bcm/spu2.c b/drivers/crypto/bcm/spu2.c
index ef04c97..bf7ac62 100644
--- a/drivers/crypto/bcm/spu2.c
+++ b/drivers/crypto/bcm/spu2.c
@@ -302,6 +302,7 @@ static int spu2_hash_mode_xlate(enum hash_mode hash_mode,
break;
case HASH_ALG_SHA3_512:
*spu2_type = SPU2_HASH_TYPE_SHA3_512;
+   break;
case HASH_ALG_LAST:
default:
err = -EINVAL;
-- 
1.9.1



[PATCH] crypto: brcm - Fix SHA3-512 algorithm failure

2017-06-23 Thread Raveendra Padasalagi
In Broadcom SPU driver, due to missing break statement
in spu2_hash_xlate() while mapping SPU2 equivalent
SHA3-512 value, -EINVAL is chosen and hence leading to
failure of SHA3-512 algorithm. This patch fixes the same.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 drivers/crypto/bcm/spu2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/bcm/spu2.c b/drivers/crypto/bcm/spu2.c
index ef04c97..bf7ac62 100644
--- a/drivers/crypto/bcm/spu2.c
+++ b/drivers/crypto/bcm/spu2.c
@@ -302,6 +302,7 @@ static int spu2_hash_mode_xlate(enum hash_mode hash_mode,
break;
case HASH_ALG_SHA3_512:
*spu2_type = SPU2_HASH_TYPE_SHA3_512;
+   break;
case HASH_ALG_LAST:
default:
err = -EINVAL;
-- 
1.9.1



[PATCH v2] iio: adc: bcm_iproc_adc: swap primary and secondary isr handler's

2017-05-16 Thread Raveendra Padasalagi
The third argument of devm_request_threaded_irq() is the primary
handler. It is called in hardirq context and checks whether the
interrupt is relevant to the device. If the primary handler returns
IRQ_WAKE_THREAD, the secondary handler (a.k.a. handler thread) is
scheduled to run in process context.

bcm_iproc_adc.c uses the secondary handler as the primary one
and the other way around. So this patch fixes the same, along with
re-naming the secondary handler and primary handler names properly.

Tested on the BCM9583XX iProc SoC based boards.

Fixes: 4324c97ecedc ("iio: Add driver for Broadcom iproc-static-adc")
Reported-by: Pavel Roskin <plros...@gmail.com>
Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Cc: sta...@vger.kernel.org
---

Changes in v2:
 - Added Cc tag in the Signed-off area to send the patch to stable kernel
 - Fixes tag corrected with proper formatting

 drivers/iio/adc/bcm_iproc_adc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
index 21d38c8..7f4f9c4 100644
--- a/drivers/iio/adc/bcm_iproc_adc.c
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -143,7 +143,7 @@ static void iproc_adc_reg_dump(struct iio_dev *indio_dev)
iproc_adc_dbg_reg(dev, adc_priv, IPROC_SOFT_BYPASS_DATA);
 }
 
-static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data)
+static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data)
 {
u32 channel_intr_status;
u32 intr_status;
@@ -167,7 +167,7 @@ static irqreturn_t iproc_adc_interrupt_handler(int irq, 
void *data)
return IRQ_NONE;
 }
 
-static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data)
+static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data)
 {
irqreturn_t retval = IRQ_NONE;
struct iproc_adc_priv *adc_priv;
@@ -181,7 +181,7 @@ static irqreturn_t iproc_adc_interrupt_thread(int irq, void 
*data)
adc_priv = iio_priv(indio_dev);
 
regmap_read(adc_priv->regmap, IPROC_INTERRUPT_STATUS, _status);
-   dev_dbg(_dev->dev, "iproc_adc_interrupt_thread(),INTRPT_STS:%x\n",
+   dev_dbg(_dev->dev, 
"iproc_adc_interrupt_handler(),INTRPT_STS:%x\n",
intr_status);
 
intr_channels = (intr_status & IPROC_ADC_INTR_MASK) >> IPROC_ADC_INTR;
@@ -566,8 +566,8 @@ static int iproc_adc_probe(struct platform_device *pdev)
}
 
ret = devm_request_threaded_irq(>dev, adc_priv->irqno,
-   iproc_adc_interrupt_thread,
iproc_adc_interrupt_handler,
+   iproc_adc_interrupt_thread,
IRQF_SHARED, "iproc-adc", indio_dev);
if (ret) {
dev_err(>dev, "request_irq error %d\n", ret);
-- 
1.9.1



[PATCH v2] iio: adc: bcm_iproc_adc: swap primary and secondary isr handler's

2017-05-16 Thread Raveendra Padasalagi
The third argument of devm_request_threaded_irq() is the primary
handler. It is called in hardirq context and checks whether the
interrupt is relevant to the device. If the primary handler returns
IRQ_WAKE_THREAD, the secondary handler (a.k.a. handler thread) is
scheduled to run in process context.

bcm_iproc_adc.c uses the secondary handler as the primary one
and the other way around. So this patch fixes the same, along with
re-naming the secondary handler and primary handler names properly.

Tested on the BCM9583XX iProc SoC based boards.

Fixes: 4324c97ecedc ("iio: Add driver for Broadcom iproc-static-adc")
Reported-by: Pavel Roskin 
Signed-off-by: Raveendra Padasalagi 
Cc: sta...@vger.kernel.org
---

Changes in v2:
 - Added Cc tag in the Signed-off area to send the patch to stable kernel
 - Fixes tag corrected with proper formatting

 drivers/iio/adc/bcm_iproc_adc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
index 21d38c8..7f4f9c4 100644
--- a/drivers/iio/adc/bcm_iproc_adc.c
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -143,7 +143,7 @@ static void iproc_adc_reg_dump(struct iio_dev *indio_dev)
iproc_adc_dbg_reg(dev, adc_priv, IPROC_SOFT_BYPASS_DATA);
 }
 
-static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data)
+static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data)
 {
u32 channel_intr_status;
u32 intr_status;
@@ -167,7 +167,7 @@ static irqreturn_t iproc_adc_interrupt_handler(int irq, 
void *data)
return IRQ_NONE;
 }
 
-static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data)
+static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data)
 {
irqreturn_t retval = IRQ_NONE;
struct iproc_adc_priv *adc_priv;
@@ -181,7 +181,7 @@ static irqreturn_t iproc_adc_interrupt_thread(int irq, void 
*data)
adc_priv = iio_priv(indio_dev);
 
regmap_read(adc_priv->regmap, IPROC_INTERRUPT_STATUS, _status);
-   dev_dbg(_dev->dev, "iproc_adc_interrupt_thread(),INTRPT_STS:%x\n",
+   dev_dbg(_dev->dev, 
"iproc_adc_interrupt_handler(),INTRPT_STS:%x\n",
intr_status);
 
intr_channels = (intr_status & IPROC_ADC_INTR_MASK) >> IPROC_ADC_INTR;
@@ -566,8 +566,8 @@ static int iproc_adc_probe(struct platform_device *pdev)
}
 
ret = devm_request_threaded_irq(>dev, adc_priv->irqno,
-   iproc_adc_interrupt_thread,
iproc_adc_interrupt_handler,
+   iproc_adc_interrupt_thread,
IRQF_SHARED, "iproc-adc", indio_dev);
if (ret) {
dev_err(>dev, "request_irq error %d\n", ret);
-- 
1.9.1



[RESEND PATCH] iio: adc: bcm_iproc_adc: swap primary and secondary isr handler's

2017-05-15 Thread Raveendra Padasalagi
The third argument of devm_request_threaded_irq() is the primary
handler. It is called in hardirq context and checks whether the
interrupt is relevant to the device. If the primary handler returns
IRQ_WAKE_THREAD, the secondary handler (a.k.a. handler thread) is
scheduled to run in process context.

bcm_iproc_adc.c uses the secondary handler as the primary one
and the other way around. So this patch fixes the same, along with
re-naming the secondary handler and primary handler names properly.

Tested on the BCM9583XX iProc SoC based boards.

Reported-by: Pavel Roskin <plros...@gmail.com>
Fixes: 4324c97ecedc("iio: Add driver for Broadcom iproc-static-adc")
Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
---
 drivers/iio/adc/bcm_iproc_adc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
index 21d38c8..7f4f9c4 100644
--- a/drivers/iio/adc/bcm_iproc_adc.c
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -143,7 +143,7 @@ static void iproc_adc_reg_dump(struct iio_dev *indio_dev)
iproc_adc_dbg_reg(dev, adc_priv, IPROC_SOFT_BYPASS_DATA);
 }
 
-static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data)
+static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data)
 {
u32 channel_intr_status;
u32 intr_status;
@@ -167,7 +167,7 @@ static irqreturn_t iproc_adc_interrupt_handler(int irq, 
void *data)
return IRQ_NONE;
 }
 
-static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data)
+static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data)
 {
irqreturn_t retval = IRQ_NONE;
struct iproc_adc_priv *adc_priv;
@@ -181,7 +181,7 @@ static irqreturn_t iproc_adc_interrupt_thread(int irq, void 
*data)
adc_priv = iio_priv(indio_dev);
 
regmap_read(adc_priv->regmap, IPROC_INTERRUPT_STATUS, _status);
-   dev_dbg(_dev->dev, "iproc_adc_interrupt_thread(),INTRPT_STS:%x\n",
+   dev_dbg(_dev->dev, 
"iproc_adc_interrupt_handler(),INTRPT_STS:%x\n",
intr_status);
 
intr_channels = (intr_status & IPROC_ADC_INTR_MASK) >> IPROC_ADC_INTR;
@@ -566,8 +566,8 @@ static int iproc_adc_probe(struct platform_device *pdev)
}
 
ret = devm_request_threaded_irq(>dev, adc_priv->irqno,
-   iproc_adc_interrupt_thread,
iproc_adc_interrupt_handler,
+   iproc_adc_interrupt_thread,
IRQF_SHARED, "iproc-adc", indio_dev);
if (ret) {
dev_err(>dev, "request_irq error %d\n", ret);
-- 
1.9.1



[RESEND PATCH] iio: adc: bcm_iproc_adc: swap primary and secondary isr handler's

2017-05-15 Thread Raveendra Padasalagi
The third argument of devm_request_threaded_irq() is the primary
handler. It is called in hardirq context and checks whether the
interrupt is relevant to the device. If the primary handler returns
IRQ_WAKE_THREAD, the secondary handler (a.k.a. handler thread) is
scheduled to run in process context.

bcm_iproc_adc.c uses the secondary handler as the primary one
and the other way around. So this patch fixes the same, along with
re-naming the secondary handler and primary handler names properly.

Tested on the BCM9583XX iProc SoC based boards.

Reported-by: Pavel Roskin 
Fixes: 4324c97ecedc("iio: Add driver for Broadcom iproc-static-adc")
Signed-off-by: Raveendra Padasalagi 
---
 drivers/iio/adc/bcm_iproc_adc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
index 21d38c8..7f4f9c4 100644
--- a/drivers/iio/adc/bcm_iproc_adc.c
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -143,7 +143,7 @@ static void iproc_adc_reg_dump(struct iio_dev *indio_dev)
iproc_adc_dbg_reg(dev, adc_priv, IPROC_SOFT_BYPASS_DATA);
 }
 
-static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data)
+static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data)
 {
u32 channel_intr_status;
u32 intr_status;
@@ -167,7 +167,7 @@ static irqreturn_t iproc_adc_interrupt_handler(int irq, 
void *data)
return IRQ_NONE;
 }
 
-static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data)
+static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data)
 {
irqreturn_t retval = IRQ_NONE;
struct iproc_adc_priv *adc_priv;
@@ -181,7 +181,7 @@ static irqreturn_t iproc_adc_interrupt_thread(int irq, void 
*data)
adc_priv = iio_priv(indio_dev);
 
regmap_read(adc_priv->regmap, IPROC_INTERRUPT_STATUS, _status);
-   dev_dbg(_dev->dev, "iproc_adc_interrupt_thread(),INTRPT_STS:%x\n",
+   dev_dbg(_dev->dev, 
"iproc_adc_interrupt_handler(),INTRPT_STS:%x\n",
intr_status);
 
intr_channels = (intr_status & IPROC_ADC_INTR_MASK) >> IPROC_ADC_INTR;
@@ -566,8 +566,8 @@ static int iproc_adc_probe(struct platform_device *pdev)
}
 
ret = devm_request_threaded_irq(>dev, adc_priv->irqno,
-   iproc_adc_interrupt_thread,
iproc_adc_interrupt_handler,
+   iproc_adc_interrupt_thread,
IRQF_SHARED, "iproc-adc", indio_dev);
if (ret) {
dev_err(>dev, "request_irq error %d\n", ret);
-- 
1.9.1



[PATCH] Crypto:Add HMAC-SHA3 test modes and test vectors

2016-06-30 Thread Raveendra Padasalagi
This patch adds HMAC-SHA3 test modes in tcrypt module
and related test vectors.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
---
 crypto/tcrypt.c  |  16 +++
 crypto/testmgr.c |  40 ++
 crypto/testmgr.h | 388 +++
 3 files changed, 444 insertions(+)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 579dce0..1ad7ffe 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -1328,6 +1328,22 @@ static int do_test(const char *alg, u32 type, u32 mask, 
int m)
ret += tcrypt_test("hmac(crc32)");
break;
 
+   case 111:
+   ret += tcrypt_test("hmac(sha3-224)");
+   break;
+
+   case 112:
+   ret += tcrypt_test("hmac(sha3-256)");
+   break;
+
+   case 113:
+   ret += tcrypt_test("hmac(sha3-384)");
+   break;
+
+   case 114:
+   ret += tcrypt_test("hmac(sha3-512)");
+   break;
+
case 150:
ret += tcrypt_test("ansi_cprng");
break;
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index c727fb0..0f93036 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -3249,6 +3249,46 @@ static const struct alg_test_desc alg_test_descs[] = {
}
}
}, {
+   .alg = "hmac(sha3-224)",
+   .test = alg_test_hash,
+   .fips_allowed = 1,
+   .suite = {
+   .hash = {
+   .vecs = hmac_sha3_224_tv_template,
+   .count = HMAC_SHA3_224_TEST_VECTORS
+   }
+   }
+   }, {
+   .alg = "hmac(sha3-256)",
+   .test = alg_test_hash,
+   .fips_allowed = 1,
+   .suite = {
+   .hash = {
+   .vecs = hmac_sha3_256_tv_template,
+   .count = HMAC_SHA3_256_TEST_VECTORS
+   }
+   }
+   }, {
+   .alg = "hmac(sha3-384)",
+   .test = alg_test_hash,
+   .fips_allowed = 1,
+   .suite = {
+   .hash = {
+   .vecs = hmac_sha3_384_tv_template,
+   .count = HMAC_SHA3_384_TEST_VECTORS
+   }
+   }
+   }, {
+   .alg = "hmac(sha3-512)",
+   .test = alg_test_hash,
+   .fips_allowed = 1,
+   .suite = {
+   .hash = {
+   .vecs = hmac_sha3_512_tv_template,
+   .count = HMAC_SHA3_512_TEST_VECTORS
+   }
+   }
+   }, {
.alg = "hmac(sha384)",
.test = alg_test_hash,
.fips_allowed = 1,
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index 487ec88..0cee15c 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -3246,6 +3246,394 @@ static struct hash_testvec hmac_sha512_tv_template[] = {
},
 };
 
+#define HMAC_SHA3_224_TEST_VECTORS 4
+
+static struct hash_testvec hmac_sha3_224_tv_template[] = {
+   {
+   .key= "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+   .ksize  = 20,
+   .plaintext = "Hi There",
+   .psize  = 8,
+   .digest = "\x3b\x16\x54\x6b\xbc\x7b\xe2\x70"
+ "\x6a\x03\x1d\xca\xfd\x56\x37\x3d"
+ "\x98\x84\x36\x76\x41\xd8\xc5\x9a"
+ "\xf3\xc8\x60\xf7",
+   }, {
+   .key= "Jefe",
+   .ksize  = 4,
+   .plaintext = "what do ya want for nothing?",
+   .psize  = 28,
+   .digest = "\x7f\xdb\x8d\xd8\x8b\xd2\xf6\x0d"
+ "\x1b\x79\x86\x34\xad\x38\x68\x11"
+ "\xc2\xcf\xc8\x5b\xfa\xf5\xd5\x2b"
+ "\xba\xce\x5e\x66",
+   .np = 4,
+   .tap= { 7, 7, 7, 7 }
+   }, {
+   .key= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa

[PATCH] Crypto:Add HMAC-SHA3 test modes and test vectors

2016-06-30 Thread Raveendra Padasalagi
This patch adds HMAC-SHA3 test modes in tcrypt module
and related test vectors.

Signed-off-by: Raveendra Padasalagi 
---
 crypto/tcrypt.c  |  16 +++
 crypto/testmgr.c |  40 ++
 crypto/testmgr.h | 388 +++
 3 files changed, 444 insertions(+)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 579dce0..1ad7ffe 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -1328,6 +1328,22 @@ static int do_test(const char *alg, u32 type, u32 mask, 
int m)
ret += tcrypt_test("hmac(crc32)");
break;
 
+   case 111:
+   ret += tcrypt_test("hmac(sha3-224)");
+   break;
+
+   case 112:
+   ret += tcrypt_test("hmac(sha3-256)");
+   break;
+
+   case 113:
+   ret += tcrypt_test("hmac(sha3-384)");
+   break;
+
+   case 114:
+   ret += tcrypt_test("hmac(sha3-512)");
+   break;
+
case 150:
ret += tcrypt_test("ansi_cprng");
break;
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index c727fb0..0f93036 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -3249,6 +3249,46 @@ static const struct alg_test_desc alg_test_descs[] = {
}
}
}, {
+   .alg = "hmac(sha3-224)",
+   .test = alg_test_hash,
+   .fips_allowed = 1,
+   .suite = {
+   .hash = {
+   .vecs = hmac_sha3_224_tv_template,
+   .count = HMAC_SHA3_224_TEST_VECTORS
+   }
+   }
+   }, {
+   .alg = "hmac(sha3-256)",
+   .test = alg_test_hash,
+   .fips_allowed = 1,
+   .suite = {
+   .hash = {
+   .vecs = hmac_sha3_256_tv_template,
+   .count = HMAC_SHA3_256_TEST_VECTORS
+   }
+   }
+   }, {
+   .alg = "hmac(sha3-384)",
+   .test = alg_test_hash,
+   .fips_allowed = 1,
+   .suite = {
+   .hash = {
+   .vecs = hmac_sha3_384_tv_template,
+   .count = HMAC_SHA3_384_TEST_VECTORS
+   }
+   }
+   }, {
+   .alg = "hmac(sha3-512)",
+   .test = alg_test_hash,
+   .fips_allowed = 1,
+   .suite = {
+   .hash = {
+   .vecs = hmac_sha3_512_tv_template,
+   .count = HMAC_SHA3_512_TEST_VECTORS
+   }
+   }
+   }, {
.alg = "hmac(sha384)",
.test = alg_test_hash,
.fips_allowed = 1,
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index 487ec88..0cee15c 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -3246,6 +3246,394 @@ static struct hash_testvec hmac_sha512_tv_template[] = {
},
 };
 
+#define HMAC_SHA3_224_TEST_VECTORS 4
+
+static struct hash_testvec hmac_sha3_224_tv_template[] = {
+   {
+   .key= "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
+ "\x0b\x0b\x0b\x0b",
+   .ksize  = 20,
+   .plaintext = "Hi There",
+   .psize  = 8,
+   .digest = "\x3b\x16\x54\x6b\xbc\x7b\xe2\x70"
+ "\x6a\x03\x1d\xca\xfd\x56\x37\x3d"
+ "\x98\x84\x36\x76\x41\xd8\xc5\x9a"
+ "\xf3\xc8\x60\xf7",
+   }, {
+   .key= "Jefe",
+   .ksize  = 4,
+   .plaintext = "what do ya want for nothing?",
+   .psize  = 28,
+   .digest = "\x7f\xdb\x8d\xd8\x8b\xd2\xf6\x0d"
+ "\x1b\x79\x86\x34\xad\x38\x68\x11"
+ "\xc2\xcf\xc8\x5b\xfa\xf5\xd5\x2b"
+ "\xba\xce\x5e\x66",
+   .np = 4,
+   .tap= { 7, 7, 7, 7 }
+   }, {
+   .key= "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
+ "

[PATCH v4 0/3] Add Broadcom iproc-static-adc controller driver

2016-06-28 Thread Raveendra Padasalagi
This patchset contains initial driver for Broadcom's
iproc static adc controller. The patchset is based on v4.7-rc1
tag and its tested on Broadcom Cygnus SoC.

The patches can be fetched from iproc-adc-v4 branch of
https://github.com/Broadcom/arm64-linux.git


Changes since v3:
 - Assigned indio_dev->name to be iproc-static-adc.
 - Modified Module Author to include the name and email address.
 - Modified DT binding document to include reference to IIO core
   docs for property io-channel-ranges.

Changes since v2:
 - Addressed various comments given by Jonathan Cameron and
   Peter Meerwald-Stadler on driver source code related to linux
   coding style and clean-up of code. Lot of source code change
   happened especially due to redefining the #defines.
 - Added code to support IIO_CHAN_INFO_SCALE mask to return
   scale value in iproc_adc_read_raw().
 - Removed #address-cells, #size-cells properties in DT binding
   document and dts file as adc will not have any child nodes as
   noticed by Rob Herring.

Changes since v1:
 - Modified Kconfig file to add more informative information
   in Broadcom Adc driver configuration menu.
 - Added Broadcom Adc driver menu config in the alphabetical
   order in Kconfig
 - Addressed various comments given by Peter Meerwald-Stadler
   on driver source code, Including issues related to linux
   coding style and race conditions.

Raveendra Padasalagi (3):
  Documentation: DT: Add iproc-static-adc binding
  iio: Add driver for Broadcom iproc-static-adc
  ARM:dts-Add dt node for Broadcom iproc-static-adc

 .../bindings/iio/adc/brcm,iproc-static-adc.txt |  41 ++
 arch/arm/boot/dts/bcm-cygnus.dtsi  |  11 +
 drivers/iio/adc/Kconfig|  12 +
 drivers/iio/adc/Makefile   |   1 +
 drivers/iio/adc/bcm_iproc_adc.c| 644 +
 5 files changed, 709 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
 create mode 100644 drivers/iio/adc/bcm_iproc_adc.c

-- 
1.9.1



[PATCH v4 0/3] Add Broadcom iproc-static-adc controller driver

2016-06-28 Thread Raveendra Padasalagi
This patchset contains initial driver for Broadcom's
iproc static adc controller. The patchset is based on v4.7-rc1
tag and its tested on Broadcom Cygnus SoC.

The patches can be fetched from iproc-adc-v4 branch of
https://github.com/Broadcom/arm64-linux.git


Changes since v3:
 - Assigned indio_dev->name to be iproc-static-adc.
 - Modified Module Author to include the name and email address.
 - Modified DT binding document to include reference to IIO core
   docs for property io-channel-ranges.

Changes since v2:
 - Addressed various comments given by Jonathan Cameron and
   Peter Meerwald-Stadler on driver source code related to linux
   coding style and clean-up of code. Lot of source code change
   happened especially due to redefining the #defines.
 - Added code to support IIO_CHAN_INFO_SCALE mask to return
   scale value in iproc_adc_read_raw().
 - Removed #address-cells, #size-cells properties in DT binding
   document and dts file as adc will not have any child nodes as
   noticed by Rob Herring.

Changes since v1:
 - Modified Kconfig file to add more informative information
   in Broadcom Adc driver configuration menu.
 - Added Broadcom Adc driver menu config in the alphabetical
   order in Kconfig
 - Addressed various comments given by Peter Meerwald-Stadler
   on driver source code, Including issues related to linux
   coding style and race conditions.

Raveendra Padasalagi (3):
  Documentation: DT: Add iproc-static-adc binding
  iio: Add driver for Broadcom iproc-static-adc
  ARM:dts-Add dt node for Broadcom iproc-static-adc

 .../bindings/iio/adc/brcm,iproc-static-adc.txt |  41 ++
 arch/arm/boot/dts/bcm-cygnus.dtsi  |  11 +
 drivers/iio/adc/Kconfig|  12 +
 drivers/iio/adc/Makefile   |   1 +
 drivers/iio/adc/bcm_iproc_adc.c| 644 +
 5 files changed, 709 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
 create mode 100644 drivers/iio/adc/bcm_iproc_adc.c

-- 
1.9.1



[PATCH v4 2/3] iio: Add driver for Broadcom iproc-static-adc

2016-06-28 Thread Raveendra Padasalagi
This patch adds basic driver implementation for Broadcom's
static adc controller used in iProc SoC's family.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
---
 drivers/iio/adc/Kconfig |  12 +
 drivers/iio/adc/Makefile|   1 +
 drivers/iio/adc/bcm_iproc_adc.c | 644 
 3 files changed, 657 insertions(+)
 create mode 100644 drivers/iio/adc/bcm_iproc_adc.c

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 25378c5..1de31bd 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -153,6 +153,18 @@ config AXP288_ADC
  To compile this driver as a module, choose M here: the module will be
  called axp288_adc.
 
+config BCM_IPROC_ADC
+   tristate "Broadcom IPROC ADC driver"
+   depends on ARCH_BCM_IPROC || COMPILE_TEST
+   depends on MFD_SYSCON
+   default ARCH_BCM_CYGNUS
+   help
+ Say Y here if you want to add support for the Broadcom static
+ ADC driver.
+
+ Broadcom iProc ADC driver. Broadcom iProc ADC controller has 8
+ channels. The driver allows the user to read voltage values.
+
 config BERLIN2_ADC
tristate "Marvell Berlin2 ADC driver"
depends on ARCH_BERLIN
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index 38638d4..0ba0d50 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_AD799X) += ad799x.o
 obj-$(CONFIG_AT91_ADC) += at91_adc.o
 obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o
 obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
+obj-$(CONFIG_BCM_IPROC_ADC) += bcm_iproc_adc.o
 obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
 obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
 obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o
diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
new file mode 100644
index 000..21d38c8
--- /dev/null
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -0,0 +1,644 @@
+/*
+ * Copyright 2016 Broadcom
+ *
+ * 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 (the "GPL").
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 (GPLv2) for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 (GPLv2) along with this source code.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/* Below Register's are common to IPROC ADC and Touchscreen IP */
+#define IPROC_REGCTL1  0x00
+#define IPROC_REGCTL2  0x04
+#define IPROC_INTERRUPT_THRES  0x08
+#define IPROC_INTERRUPT_MASK   0x0c
+#define IPROC_INTERRUPT_STATUS 0x10
+#define IPROC_ANALOG_CONTROL   0x1c
+#define IPROC_CONTROLLER_STATUS0x14
+#define IPROC_AUX_DATA 0x20
+#define IPROC_SOFT_BYPASS_CONTROL  0x38
+#define IPROC_SOFT_BYPASS_DATA 0x3C
+
+/* IPROC ADC Channel register offsets */
+#define IPROC_ADC_CHANNEL_REGCTL1  0x800
+#define IPROC_ADC_CHANNEL_REGCTL2  0x804
+#define IPROC_ADC_CHANNEL_STATUS   0x808
+#define IPROC_ADC_CHANNEL_INTERRUPT_STATUS 0x80c
+#define IPROC_ADC_CHANNEL_INTERRUPT_MASK   0x810
+#define IPROC_ADC_CHANNEL_DATA 0x814
+#define IPROC_ADC_CHANNEL_OFFSET   0x20
+
+/* Bit definitions for IPROC_REGCTL2 */
+#define IPROC_ADC_AUXIN_SCAN_ENA   BIT(0)
+#define IPROC_ADC_PWR_LDO  BIT(5)
+#define IPROC_ADC_PWR_ADC  BIT(4)
+#define IPROC_ADC_PWR_BG   BIT(3)
+#define IPROC_ADC_CONTROLLER_ENBIT(17)
+
+/* Bit definitions for IPROC_INTERRUPT_MASK and IPROC_INTERRUPT_STATUS */
+#define IPROC_ADC_AUXDATA_RDY_INTR BIT(3)
+#define IPROC_ADC_INTR 9
+#define IPROC_ADC_INTR_MASK(0xFF << IPROC_ADC_INTR)
+
+/* Bit definitions for IPROC_ANALOG_CONTROL */
+#define IPROC_ADC_CHANNEL_SEL  11
+#define IPROC_ADC_CHANNEL_SEL_MASK (0x7 << IPROC_ADC_CHANNEL_SEL)
+
+/* Bit definitions for IPROC_ADC_CHANNEL_REGCTL1 */
+#define IPROC_ADC_CHANNEL_ROUNDS   0x2
+#define IPROC_ADC_CHANNEL_ROUNDS_MASK  (0x3F << IPROC_ADC_CHANNEL_ROUNDS)
+#define IPROC_ADC_CHANNEL_MODE 0x1
+#define IPROC_ADC_CHANNEL_MODE_MASK(0x1 << IPROC_ADC_CHANNEL_MODE)
+#define IPROC_ADC_CHANNEL_MODE_TDM 0x1
+#define IPROC_ADC_CHANNEL_MODE_SNAPSHOT 0x0
+#define IPROC_ADC_CHANNEL_ENABLE   0x0
+#define IPROC_ADC_CHAN

[PATCH v4 2/3] iio: Add driver for Broadcom iproc-static-adc

2016-06-28 Thread Raveendra Padasalagi
This patch adds basic driver implementation for Broadcom's
static adc controller used in iProc SoC's family.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 drivers/iio/adc/Kconfig |  12 +
 drivers/iio/adc/Makefile|   1 +
 drivers/iio/adc/bcm_iproc_adc.c | 644 
 3 files changed, 657 insertions(+)
 create mode 100644 drivers/iio/adc/bcm_iproc_adc.c

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 25378c5..1de31bd 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -153,6 +153,18 @@ config AXP288_ADC
  To compile this driver as a module, choose M here: the module will be
  called axp288_adc.
 
+config BCM_IPROC_ADC
+   tristate "Broadcom IPROC ADC driver"
+   depends on ARCH_BCM_IPROC || COMPILE_TEST
+   depends on MFD_SYSCON
+   default ARCH_BCM_CYGNUS
+   help
+ Say Y here if you want to add support for the Broadcom static
+ ADC driver.
+
+ Broadcom iProc ADC driver. Broadcom iProc ADC controller has 8
+ channels. The driver allows the user to read voltage values.
+
 config BERLIN2_ADC
tristate "Marvell Berlin2 ADC driver"
depends on ARCH_BERLIN
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index 38638d4..0ba0d50 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_AD799X) += ad799x.o
 obj-$(CONFIG_AT91_ADC) += at91_adc.o
 obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o
 obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
+obj-$(CONFIG_BCM_IPROC_ADC) += bcm_iproc_adc.o
 obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
 obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
 obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o
diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
new file mode 100644
index 000..21d38c8
--- /dev/null
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -0,0 +1,644 @@
+/*
+ * Copyright 2016 Broadcom
+ *
+ * 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 (the "GPL").
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 (GPLv2) for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 (GPLv2) along with this source code.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/* Below Register's are common to IPROC ADC and Touchscreen IP */
+#define IPROC_REGCTL1  0x00
+#define IPROC_REGCTL2  0x04
+#define IPROC_INTERRUPT_THRES  0x08
+#define IPROC_INTERRUPT_MASK   0x0c
+#define IPROC_INTERRUPT_STATUS 0x10
+#define IPROC_ANALOG_CONTROL   0x1c
+#define IPROC_CONTROLLER_STATUS0x14
+#define IPROC_AUX_DATA 0x20
+#define IPROC_SOFT_BYPASS_CONTROL  0x38
+#define IPROC_SOFT_BYPASS_DATA 0x3C
+
+/* IPROC ADC Channel register offsets */
+#define IPROC_ADC_CHANNEL_REGCTL1  0x800
+#define IPROC_ADC_CHANNEL_REGCTL2  0x804
+#define IPROC_ADC_CHANNEL_STATUS   0x808
+#define IPROC_ADC_CHANNEL_INTERRUPT_STATUS 0x80c
+#define IPROC_ADC_CHANNEL_INTERRUPT_MASK   0x810
+#define IPROC_ADC_CHANNEL_DATA 0x814
+#define IPROC_ADC_CHANNEL_OFFSET   0x20
+
+/* Bit definitions for IPROC_REGCTL2 */
+#define IPROC_ADC_AUXIN_SCAN_ENA   BIT(0)
+#define IPROC_ADC_PWR_LDO  BIT(5)
+#define IPROC_ADC_PWR_ADC  BIT(4)
+#define IPROC_ADC_PWR_BG   BIT(3)
+#define IPROC_ADC_CONTROLLER_ENBIT(17)
+
+/* Bit definitions for IPROC_INTERRUPT_MASK and IPROC_INTERRUPT_STATUS */
+#define IPROC_ADC_AUXDATA_RDY_INTR BIT(3)
+#define IPROC_ADC_INTR 9
+#define IPROC_ADC_INTR_MASK(0xFF << IPROC_ADC_INTR)
+
+/* Bit definitions for IPROC_ANALOG_CONTROL */
+#define IPROC_ADC_CHANNEL_SEL  11
+#define IPROC_ADC_CHANNEL_SEL_MASK (0x7 << IPROC_ADC_CHANNEL_SEL)
+
+/* Bit definitions for IPROC_ADC_CHANNEL_REGCTL1 */
+#define IPROC_ADC_CHANNEL_ROUNDS   0x2
+#define IPROC_ADC_CHANNEL_ROUNDS_MASK  (0x3F << IPROC_ADC_CHANNEL_ROUNDS)
+#define IPROC_ADC_CHANNEL_MODE 0x1
+#define IPROC_ADC_CHANNEL_MODE_MASK(0x1 << IPROC_ADC_CHANNEL_MODE)
+#define IPROC_ADC_CHANNEL_MODE_TDM 0x1
+#define IPROC_ADC_CHANNEL_MODE_SNAPSHOT 0x0
+#define IPROC_ADC_CHANNEL_ENABLE   0x0
+#define IPROC_ADC_CHANNEL_ENABLE_MASK  0x1
+
+/* Bit definitions for IPROC_ADC_CHANNEL_REGCTL2 */
+#define IPROC_ADC_CHANNEL_WATE

[PATCH v4 1/3] Documentation: DT: Add iproc-static-adc binding

2016-06-28 Thread Raveendra Padasalagi
The patch adds devicetree binding document for broadcom's
iproc-static-adc controller driver.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
---
 .../bindings/iio/adc/brcm,iproc-static-adc.txt | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt

diff --git 
a/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt 
b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
new file mode 100644
index 000..caaaed7
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
@@ -0,0 +1,41 @@
+* Broadcom's IPROC Static ADC controller
+
+Broadcom iProc ADC controller has 8 channels 10bit ADC.
+Allows user to convert analog input voltage values to digital.
+
+Required properties:
+
+- compatible: Must be "brcm,iproc-static-adc"
+
+- adc-syscon: Handler of syscon node defining physical base address of the
+  controller and length of memory mapped region.
+
+- #io-channel-cells = <1>; As ADC has multiple outputs
+  refer to Documentation/devicetree/bindings/iio/iio-bindings.txt for details.
+
+- io-channel-ranges:
+  refer to Documentation/devicetree/bindings/iio/iio-bindings.txt for details.
+
+- clocks: Clock used for this block.
+
+- clock-names: Clock name should be given as tsc_clk.
+
+- interrupts: interrupt line number.
+
+For example:
+
+   ts_adc_syscon: ts_adc_syscon@180a6000 {
+   compatible = "brcm,iproc-ts-adc-syscon","syscon";
+   reg = <0x180a6000 0xc30>;
+   };
+
+   adc: adc@180a6000 {
+   compatible = "brcm,iproc-static-adc";
+   adc-syscon = <_adc_syscon>;
+   #io-channel-cells = <1>;
+   io-channel-ranges;
+   clocks = <_clks BCM_CYGNUS_ASIU_ADC_CLK>;
+   clock-names = "tsc_clk";
+   interrupts = ;
+   status = "disabled";
+   };
-- 
1.9.1



[PATCH v4 1/3] Documentation: DT: Add iproc-static-adc binding

2016-06-28 Thread Raveendra Padasalagi
The patch adds devicetree binding document for broadcom's
iproc-static-adc controller driver.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 .../bindings/iio/adc/brcm,iproc-static-adc.txt | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt

diff --git 
a/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt 
b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
new file mode 100644
index 000..caaaed7
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
@@ -0,0 +1,41 @@
+* Broadcom's IPROC Static ADC controller
+
+Broadcom iProc ADC controller has 8 channels 10bit ADC.
+Allows user to convert analog input voltage values to digital.
+
+Required properties:
+
+- compatible: Must be "brcm,iproc-static-adc"
+
+- adc-syscon: Handler of syscon node defining physical base address of the
+  controller and length of memory mapped region.
+
+- #io-channel-cells = <1>; As ADC has multiple outputs
+  refer to Documentation/devicetree/bindings/iio/iio-bindings.txt for details.
+
+- io-channel-ranges:
+  refer to Documentation/devicetree/bindings/iio/iio-bindings.txt for details.
+
+- clocks: Clock used for this block.
+
+- clock-names: Clock name should be given as tsc_clk.
+
+- interrupts: interrupt line number.
+
+For example:
+
+   ts_adc_syscon: ts_adc_syscon@180a6000 {
+   compatible = "brcm,iproc-ts-adc-syscon","syscon";
+   reg = <0x180a6000 0xc30>;
+   };
+
+   adc: adc@180a6000 {
+   compatible = "brcm,iproc-static-adc";
+   adc-syscon = <_adc_syscon>;
+   #io-channel-cells = <1>;
+   io-channel-ranges;
+   clocks = <_clks BCM_CYGNUS_ASIU_ADC_CLK>;
+   clock-names = "tsc_clk";
+   interrupts = ;
+   status = "disabled";
+   };
-- 
1.9.1



[PATCH v4 3/3] ARM:dts-Add dt node for Broadcom iproc-static-adc

2016-06-28 Thread Raveendra Padasalagi
This patch adds DT node for Broadcom's iproc-static-adc
controller driver.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
---
 arch/arm/boot/dts/bcm-cygnus.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi 
b/arch/arm/boot/dts/bcm-cygnus.dtsi
index b42fe55..fabc9f3 100644
--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
+++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
@@ -366,5 +366,16 @@
interrupts = ;
status = "disabled";
};
+
+   adc: adc@180a6000 {
+   compatible = "brcm,iproc-static-adc";
+   #io-channel-cells = <1>;
+   io-channel-ranges;
+   adc-syscon = <_adc_syscon>;
+   clocks = <_clks BCM_CYGNUS_ASIU_ADC_CLK>;
+   clock-names = "tsc_clk";
+   interrupts = ;
+   status = "disabled";
+   };
};
 };
-- 
1.9.1



[PATCH v4 3/3] ARM:dts-Add dt node for Broadcom iproc-static-adc

2016-06-28 Thread Raveendra Padasalagi
This patch adds DT node for Broadcom's iproc-static-adc
controller driver.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 arch/arm/boot/dts/bcm-cygnus.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi 
b/arch/arm/boot/dts/bcm-cygnus.dtsi
index b42fe55..fabc9f3 100644
--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
+++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
@@ -366,5 +366,16 @@
interrupts = ;
status = "disabled";
};
+
+   adc: adc@180a6000 {
+   compatible = "brcm,iproc-static-adc";
+   #io-channel-cells = <1>;
+   io-channel-ranges;
+   adc-syscon = <_adc_syscon>;
+   clocks = <_clks BCM_CYGNUS_ASIU_ADC_CLK>;
+   clock-names = "tsc_clk";
+   interrupts = ;
+   status = "disabled";
+   };
};
 };
-- 
1.9.1



RE: [PATCH v3 2/3] iio: Add driver for Broadcom iproc-static-adc

2016-06-27 Thread Raveendra Padasalagi
> -Original Message-
> From: Jonathan Cameron [mailto:ji...@kernel.org]
> Sent: 28 June 2016 00:41
> To: Raveendra Padasalagi
> Cc: Peter Meerwald-Stadler; Rob Herring; Russell King; Arnd Bergmann;
> linux-
> i...@vger.kernel.org; devicet...@vger.kernel.org; linux-arm-
> ker...@lists.infradead.org; Pawel Moll; Mark Rutland; Ian Campbell; Kumar
> Gala; Jonathan Richardson; Jon Mason; Florian Fainelli; Anup Patel; Ray
> Jui;
> Scott Branden; Pramod Kumar; linux-kernel@vger.kernel.org; bcm-kernel-
> feedback-list
> Subject: Re: [PATCH v3 2/3] iio: Add driver for Broadcom iproc-static-adc
>
> On 27/06/16 07:25, Raveendra Padasalagi wrote:
> > On Sun, Jun 26, 2016 at 4:08 PM, Jonathan Cameron <ji...@kernel.org>
> wrote:
> >> On 22/06/16 07:11, Raveendra Padasalagi wrote:
> >>> This patch adds basic driver implementation for Broadcom's static
> >>> adc controller used in iProc SoC's family.
> >>>
> >>> Signed-off-by: Raveendra Padasalagi
> >>> <raveendra.padasal...@broadcom.com>
> >>> Reviewed-by: Ray Jui <ray@broadcom.com>
> >>> Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
> >> A few tiny nitpicks.. Otherwise, looking good to me.
> >>
> >> Thanks,
> >>
> >> Jonathan
> >
> > Thank you.  I have provided my view on naming "indio_dev->name" below.
> > Need your opinion/suggestion on the same to address it.
> >
> >>> ---
> >>>  drivers/iio/adc/Kconfig |  12 +
> >>>  drivers/iio/adc/Makefile|   1 +
> >>>  drivers/iio/adc/bcm_iproc_adc.c | 648
> >>> 
> >>>  3 files changed, 661 insertions(+)
> >>>  create mode 100644 drivers/iio/adc/bcm_iproc_adc.c
> >>>
> >>> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index
> >>> 25378c5..1de31bd 100644
> >>> --- a/drivers/iio/adc/Kconfig
> >>> +++ b/drivers/iio/adc/Kconfig
> >>> @@ -153,6 +153,18 @@ config AXP288_ADC
> >>> To compile this driver as a module, choose M here: the module
> >>> will be
> >>> called axp288_adc.
> >>>
> >>> +config BCM_IPROC_ADC
> >>> + tristate "Broadcom IPROC ADC driver"
> >>> + depends on ARCH_BCM_IPROC || COMPILE_TEST
> >>> + depends on MFD_SYSCON
> >>> + default ARCH_BCM_CYGNUS
> >>> + help
> >>> +   Say Y here if you want to add support for the Broadcom static
> >>> +   ADC driver.
> >>> +
> >>> +   Broadcom iProc ADC driver. Broadcom iProc ADC controller has 8
> >>> +   channels. The driver allows the user to read voltage values.
> >>> +
> >>>  config BERLIN2_ADC
> >>>   tristate "Marvell Berlin2 ADC driver"
> >>>   depends on ARCH_BERLIN
> >>> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> >>> index 38638d4..0ba0d50 100644
> >>> --- a/drivers/iio/adc/Makefile
> >>> +++ b/drivers/iio/adc/Makefile
> >>> @@ -16,6 +16,7 @@ obj-$(CONFIG_AD799X) += ad799x.o
> >>>  obj-$(CONFIG_AT91_ADC) += at91_adc.o
> >>>  obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o
> >>>  obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
> >>> +obj-$(CONFIG_BCM_IPROC_ADC) += bcm_iproc_adc.o
> >>>  obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
> >>>  obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
> >>>  obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o diff --git
> >>> a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
> >>> new file mode 100644 index 000..e10f6ce
> >>> --- /dev/null
> >>> +++ b/drivers/iio/adc/bcm_iproc_adc.c
> >>> @@ -0,0 +1,648 @@
> >>> +/*
> >>> + * Copyright 2016 Broadcom
> >>> + *
> >>> + * 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 (the "GPL").
> >>> + *
> >>> + * This program is distributed in the hope that it will be useful,
> >>> +but
> >>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> >>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >>> +GNU
>

RE: [PATCH v3 2/3] iio: Add driver for Broadcom iproc-static-adc

2016-06-27 Thread Raveendra Padasalagi
> -Original Message-
> From: Jonathan Cameron [mailto:ji...@kernel.org]
> Sent: 28 June 2016 00:41
> To: Raveendra Padasalagi
> Cc: Peter Meerwald-Stadler; Rob Herring; Russell King; Arnd Bergmann;
> linux-
> i...@vger.kernel.org; devicet...@vger.kernel.org; linux-arm-
> ker...@lists.infradead.org; Pawel Moll; Mark Rutland; Ian Campbell; Kumar
> Gala; Jonathan Richardson; Jon Mason; Florian Fainelli; Anup Patel; Ray
> Jui;
> Scott Branden; Pramod Kumar; linux-kernel@vger.kernel.org; bcm-kernel-
> feedback-list
> Subject: Re: [PATCH v3 2/3] iio: Add driver for Broadcom iproc-static-adc
>
> On 27/06/16 07:25, Raveendra Padasalagi wrote:
> > On Sun, Jun 26, 2016 at 4:08 PM, Jonathan Cameron 
> wrote:
> >> On 22/06/16 07:11, Raveendra Padasalagi wrote:
> >>> This patch adds basic driver implementation for Broadcom's static
> >>> adc controller used in iProc SoC's family.
> >>>
> >>> Signed-off-by: Raveendra Padasalagi
> >>> 
> >>> Reviewed-by: Ray Jui 
> >>> Reviewed-by: Scott Branden 
> >> A few tiny nitpicks.. Otherwise, looking good to me.
> >>
> >> Thanks,
> >>
> >> Jonathan
> >
> > Thank you.  I have provided my view on naming "indio_dev->name" below.
> > Need your opinion/suggestion on the same to address it.
> >
> >>> ---
> >>>  drivers/iio/adc/Kconfig |  12 +
> >>>  drivers/iio/adc/Makefile|   1 +
> >>>  drivers/iio/adc/bcm_iproc_adc.c | 648
> >>> 
> >>>  3 files changed, 661 insertions(+)
> >>>  create mode 100644 drivers/iio/adc/bcm_iproc_adc.c
> >>>
> >>> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index
> >>> 25378c5..1de31bd 100644
> >>> --- a/drivers/iio/adc/Kconfig
> >>> +++ b/drivers/iio/adc/Kconfig
> >>> @@ -153,6 +153,18 @@ config AXP288_ADC
> >>> To compile this driver as a module, choose M here: the module
> >>> will be
> >>> called axp288_adc.
> >>>
> >>> +config BCM_IPROC_ADC
> >>> + tristate "Broadcom IPROC ADC driver"
> >>> + depends on ARCH_BCM_IPROC || COMPILE_TEST
> >>> + depends on MFD_SYSCON
> >>> + default ARCH_BCM_CYGNUS
> >>> + help
> >>> +   Say Y here if you want to add support for the Broadcom static
> >>> +   ADC driver.
> >>> +
> >>> +   Broadcom iProc ADC driver. Broadcom iProc ADC controller has 8
> >>> +   channels. The driver allows the user to read voltage values.
> >>> +
> >>>  config BERLIN2_ADC
> >>>   tristate "Marvell Berlin2 ADC driver"
> >>>   depends on ARCH_BERLIN
> >>> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> >>> index 38638d4..0ba0d50 100644
> >>> --- a/drivers/iio/adc/Makefile
> >>> +++ b/drivers/iio/adc/Makefile
> >>> @@ -16,6 +16,7 @@ obj-$(CONFIG_AD799X) += ad799x.o
> >>>  obj-$(CONFIG_AT91_ADC) += at91_adc.o
> >>>  obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o
> >>>  obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
> >>> +obj-$(CONFIG_BCM_IPROC_ADC) += bcm_iproc_adc.o
> >>>  obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
> >>>  obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
> >>>  obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o diff --git
> >>> a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
> >>> new file mode 100644 index 000..e10f6ce
> >>> --- /dev/null
> >>> +++ b/drivers/iio/adc/bcm_iproc_adc.c
> >>> @@ -0,0 +1,648 @@
> >>> +/*
> >>> + * Copyright 2016 Broadcom
> >>> + *
> >>> + * 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 (the "GPL").
> >>> + *
> >>> + * This program is distributed in the hope that it will be useful,
> >>> +but
> >>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> >>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >>> +GNU
> >>> + * General Public License version 2 (GPLv2) for more details.
> >>> + *
> >>> + *

Re: [PATCH v3 1/3] Documentation: DT: Add iproc-static-adc binding

2016-06-27 Thread Raveendra Padasalagi
On Sun, Jun 26, 2016 at 3:54 PM, Jonathan Cameron <ji...@kernel.org> wrote:
> On 24/06/16 16:43, Rob Herring wrote:
>> On Wed, Jun 22, 2016 at 11:41:51AM +0530, Raveendra Padasalagi wrote:
>>> The patch adds devicetree binding document for broadcom's
>>> iproc-static-adc controller driver.
>>>
>>> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
>>> Reviewed-by: Ray Jui <ray@broadcom.com>
>>> Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
>>> ---
>>>  .../bindings/iio/adc/brcm,iproc-static-adc.txt | 38 
>>> ++
>>>  1 file changed, 38 insertions(+)
>>>  create mode 100644 
>>> Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
>>>
>>> diff --git 
>>> a/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt 
>>> b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
>>> new file mode 100644
>>> index 000..a82076e
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
>>> @@ -0,0 +1,38 @@
>>> +* Broadcom's IPROC Static ADC controller
>>> +
>>> +Broadcom iProc ADC controller has 8 channels 10bit ADC.
>>> +Allows user to convert analog input voltage values to digital.
>>> +
>>> +Required properties:
>>> +
>>> +- compatible: Must be "brcm,iproc-static-adc"
>>> +
>>> +- adc-syscon: Handler of syscon node defining physical base address of the
>>> +  controller and length of memory mapped region.
>>> +
>>> +- #io-channel-cells = <1>; As ADC has multiple outputs
>>> +  refer to Documentation/devicetree/bindings/iio/iio-bindings.txt for 
>>> details.
>>> +
>>> +- clocks: Clock used for this block.
>>> +
>>> +- clock-names: Clock name should be given as tsc_clk.
>>> +
>>> +- interrupts: interrupt line number.
>>> +
>>> +For example:
>>> +
>>> +ts_adc_syscon: ts_adc_syscon@180a6000 {
>>> +compatible = "brcm,iproc-ts-adc-syscon","syscon";
>>> +reg = <0x180a6000 0xc30>;
>>> +};
>>> +
>>> +adc: adc@180a6000 {
>>> +compatible = "brcm,iproc-static-adc";
>>> +adc-syscon = <_adc_syscon>;
>>> +#io-channel-cells = <1>;
>>> +io-channel-ranges;
>>
>> Not documented.
> Core iio docs, but obviously a cross reference would be good.

Yes, Will provide the cross reference to core iio docs in the next patch.
Thanks.

>>
>>> +clocks = <_clks BCM_CYGNUS_ASIU_ADC_CLK>;
>>> +clock-names = "tsc_clk";
>>> +interrupts = ;
>>> +status = "disabled";
>>> +};
>>> --
>>> 1.9.1
>>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>


Re: [PATCH v3 1/3] Documentation: DT: Add iproc-static-adc binding

2016-06-27 Thread Raveendra Padasalagi
On Sun, Jun 26, 2016 at 3:54 PM, Jonathan Cameron  wrote:
> On 24/06/16 16:43, Rob Herring wrote:
>> On Wed, Jun 22, 2016 at 11:41:51AM +0530, Raveendra Padasalagi wrote:
>>> The patch adds devicetree binding document for broadcom's
>>> iproc-static-adc controller driver.
>>>
>>> Signed-off-by: Raveendra Padasalagi 
>>> Reviewed-by: Ray Jui 
>>> Reviewed-by: Scott Branden 
>>> ---
>>>  .../bindings/iio/adc/brcm,iproc-static-adc.txt | 38 
>>> ++
>>>  1 file changed, 38 insertions(+)
>>>  create mode 100644 
>>> Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
>>>
>>> diff --git 
>>> a/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt 
>>> b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
>>> new file mode 100644
>>> index 000..a82076e
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
>>> @@ -0,0 +1,38 @@
>>> +* Broadcom's IPROC Static ADC controller
>>> +
>>> +Broadcom iProc ADC controller has 8 channels 10bit ADC.
>>> +Allows user to convert analog input voltage values to digital.
>>> +
>>> +Required properties:
>>> +
>>> +- compatible: Must be "brcm,iproc-static-adc"
>>> +
>>> +- adc-syscon: Handler of syscon node defining physical base address of the
>>> +  controller and length of memory mapped region.
>>> +
>>> +- #io-channel-cells = <1>; As ADC has multiple outputs
>>> +  refer to Documentation/devicetree/bindings/iio/iio-bindings.txt for 
>>> details.
>>> +
>>> +- clocks: Clock used for this block.
>>> +
>>> +- clock-names: Clock name should be given as tsc_clk.
>>> +
>>> +- interrupts: interrupt line number.
>>> +
>>> +For example:
>>> +
>>> +ts_adc_syscon: ts_adc_syscon@180a6000 {
>>> +compatible = "brcm,iproc-ts-adc-syscon","syscon";
>>> +reg = <0x180a6000 0xc30>;
>>> +};
>>> +
>>> +adc: adc@180a6000 {
>>> +compatible = "brcm,iproc-static-adc";
>>> +adc-syscon = <_adc_syscon>;
>>> +#io-channel-cells = <1>;
>>> +io-channel-ranges;
>>
>> Not documented.
> Core iio docs, but obviously a cross reference would be good.

Yes, Will provide the cross reference to core iio docs in the next patch.
Thanks.

>>
>>> +clocks = <_clks BCM_CYGNUS_ASIU_ADC_CLK>;
>>> +clock-names = "tsc_clk";
>>> +interrupts = ;
>>> +status = "disabled";
>>> +};
>>> --
>>> 1.9.1
>>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>


Re: [PATCH v3 2/3] iio: Add driver for Broadcom iproc-static-adc

2016-06-27 Thread Raveendra Padasalagi
On Sun, Jun 26, 2016 at 4:08 PM, Jonathan Cameron <ji...@kernel.org> wrote:
> On 22/06/16 07:11, Raveendra Padasalagi wrote:
>> This patch adds basic driver implementation for Broadcom's
>> static adc controller used in iProc SoC's family.
>>
>> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
>> Reviewed-by: Ray Jui <ray@broadcom.com>
>> Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
> A few tiny nitpicks.. Otherwise, looking good to me.
>
> Thanks,
>
> Jonathan

Thank you.  I have provided my view on naming "indio_dev->name" below.
Need your opinion/suggestion on the same to address it.

>> ---
>>  drivers/iio/adc/Kconfig |  12 +
>>  drivers/iio/adc/Makefile|   1 +
>>  drivers/iio/adc/bcm_iproc_adc.c | 648 
>> 
>>  3 files changed, 661 insertions(+)
>>  create mode 100644 drivers/iio/adc/bcm_iproc_adc.c
>>
>> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>> index 25378c5..1de31bd 100644
>> --- a/drivers/iio/adc/Kconfig
>> +++ b/drivers/iio/adc/Kconfig
>> @@ -153,6 +153,18 @@ config AXP288_ADC
>> To compile this driver as a module, choose M here: the module will be
>> called axp288_adc.
>>
>> +config BCM_IPROC_ADC
>> + tristate "Broadcom IPROC ADC driver"
>> + depends on ARCH_BCM_IPROC || COMPILE_TEST
>> + depends on MFD_SYSCON
>> + default ARCH_BCM_CYGNUS
>> + help
>> +   Say Y here if you want to add support for the Broadcom static
>> +   ADC driver.
>> +
>> +   Broadcom iProc ADC driver. Broadcom iProc ADC controller has 8
>> +   channels. The driver allows the user to read voltage values.
>> +
>>  config BERLIN2_ADC
>>   tristate "Marvell Berlin2 ADC driver"
>>   depends on ARCH_BERLIN
>> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
>> index 38638d4..0ba0d50 100644
>> --- a/drivers/iio/adc/Makefile
>> +++ b/drivers/iio/adc/Makefile
>> @@ -16,6 +16,7 @@ obj-$(CONFIG_AD799X) += ad799x.o
>>  obj-$(CONFIG_AT91_ADC) += at91_adc.o
>>  obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o
>>  obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
>> +obj-$(CONFIG_BCM_IPROC_ADC) += bcm_iproc_adc.o
>>  obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
>>  obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
>>  obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o
>> diff --git a/drivers/iio/adc/bcm_iproc_adc.c 
>> b/drivers/iio/adc/bcm_iproc_adc.c
>> new file mode 100644
>> index 000..e10f6ce
>> --- /dev/null
>> +++ b/drivers/iio/adc/bcm_iproc_adc.c
>> @@ -0,0 +1,648 @@
>> +/*
>> + * Copyright 2016 Broadcom
>> + *
>> + * 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 (the "GPL").
>> + *
>> + * This program is distributed in the hope that it will be useful, but
>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * General Public License version 2 (GPLv2) for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * version 2 (GPLv2) along with this source code.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +
>> +/* Below Register's are common to IPROC ADC and Touchscreen IP */
>> +#define IPROC_REGCTL10x00
>> +#define IPROC_REGCTL20x04
>> +#define IPROC_INTERRUPT_THRES0x08
>> +#define IPROC_INTERRUPT_MASK 0x0c
>> +#define IPROC_INTERRUPT_STATUS   0x10
>> +#define IPROC_ANALOG_CONTROL 0x1c
>> +#define IPROC_CONTROLLER_STATUS  0x14
>> +#define IPROC_AUX_DATA   0x20
>> +#define IPROC_SOFT_BYPASS_CONTROL0x38
>> +#define IPROC_SOFT_BYPASS_DATA   0x3C
>> +
>> +/* IPROC ADC Channel register offsets */
>> +#define IPROC_ADC_CHANNEL_REGCTL10x800
>> +#define IPROC_ADC_CHANNEL_REGCTL20x804
>> +#define IPROC_ADC_CHANNEL_STATUS 0x808
>> +#define IPROC_ADC_CHANNEL_INTERRUPT_STATUS   0x80c
>> +#define IPROC_ADC_CHANNEL_INTERR

Re: [PATCH v3 2/3] iio: Add driver for Broadcom iproc-static-adc

2016-06-27 Thread Raveendra Padasalagi
On Sun, Jun 26, 2016 at 4:08 PM, Jonathan Cameron  wrote:
> On 22/06/16 07:11, Raveendra Padasalagi wrote:
>> This patch adds basic driver implementation for Broadcom's
>> static adc controller used in iProc SoC's family.
>>
>> Signed-off-by: Raveendra Padasalagi 
>> Reviewed-by: Ray Jui 
>> Reviewed-by: Scott Branden 
> A few tiny nitpicks.. Otherwise, looking good to me.
>
> Thanks,
>
> Jonathan

Thank you.  I have provided my view on naming "indio_dev->name" below.
Need your opinion/suggestion on the same to address it.

>> ---
>>  drivers/iio/adc/Kconfig |  12 +
>>  drivers/iio/adc/Makefile|   1 +
>>  drivers/iio/adc/bcm_iproc_adc.c | 648 
>> 
>>  3 files changed, 661 insertions(+)
>>  create mode 100644 drivers/iio/adc/bcm_iproc_adc.c
>>
>> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>> index 25378c5..1de31bd 100644
>> --- a/drivers/iio/adc/Kconfig
>> +++ b/drivers/iio/adc/Kconfig
>> @@ -153,6 +153,18 @@ config AXP288_ADC
>> To compile this driver as a module, choose M here: the module will be
>> called axp288_adc.
>>
>> +config BCM_IPROC_ADC
>> + tristate "Broadcom IPROC ADC driver"
>> + depends on ARCH_BCM_IPROC || COMPILE_TEST
>> + depends on MFD_SYSCON
>> + default ARCH_BCM_CYGNUS
>> + help
>> +   Say Y here if you want to add support for the Broadcom static
>> +   ADC driver.
>> +
>> +   Broadcom iProc ADC driver. Broadcom iProc ADC controller has 8
>> +   channels. The driver allows the user to read voltage values.
>> +
>>  config BERLIN2_ADC
>>   tristate "Marvell Berlin2 ADC driver"
>>   depends on ARCH_BERLIN
>> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
>> index 38638d4..0ba0d50 100644
>> --- a/drivers/iio/adc/Makefile
>> +++ b/drivers/iio/adc/Makefile
>> @@ -16,6 +16,7 @@ obj-$(CONFIG_AD799X) += ad799x.o
>>  obj-$(CONFIG_AT91_ADC) += at91_adc.o
>>  obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o
>>  obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
>> +obj-$(CONFIG_BCM_IPROC_ADC) += bcm_iproc_adc.o
>>  obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
>>  obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
>>  obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o
>> diff --git a/drivers/iio/adc/bcm_iproc_adc.c 
>> b/drivers/iio/adc/bcm_iproc_adc.c
>> new file mode 100644
>> index 000..e10f6ce
>> --- /dev/null
>> +++ b/drivers/iio/adc/bcm_iproc_adc.c
>> @@ -0,0 +1,648 @@
>> +/*
>> + * Copyright 2016 Broadcom
>> + *
>> + * 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 (the "GPL").
>> + *
>> + * This program is distributed in the hope that it will be useful, but
>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * General Public License version 2 (GPLv2) for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * version 2 (GPLv2) along with this source code.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +
>> +/* Below Register's are common to IPROC ADC and Touchscreen IP */
>> +#define IPROC_REGCTL10x00
>> +#define IPROC_REGCTL20x04
>> +#define IPROC_INTERRUPT_THRES0x08
>> +#define IPROC_INTERRUPT_MASK 0x0c
>> +#define IPROC_INTERRUPT_STATUS   0x10
>> +#define IPROC_ANALOG_CONTROL 0x1c
>> +#define IPROC_CONTROLLER_STATUS  0x14
>> +#define IPROC_AUX_DATA   0x20
>> +#define IPROC_SOFT_BYPASS_CONTROL0x38
>> +#define IPROC_SOFT_BYPASS_DATA   0x3C
>> +
>> +/* IPROC ADC Channel register offsets */
>> +#define IPROC_ADC_CHANNEL_REGCTL10x800
>> +#define IPROC_ADC_CHANNEL_REGCTL20x804
>> +#define IPROC_ADC_CHANNEL_STATUS 0x808
>> +#define IPROC_ADC_CHANNEL_INTERRUPT_STATUS   0x80c
>> +#define IPROC_ADC_CHANNEL_INTERRUPT_MASK 0x810
>> +#define IPROC_ADC_CHANNEL_DATA   0x814
>> +#define IPROC_ADC_CHANNEL_OFFS

[PATCH v3 3/3] ARM:dts-Add dt node for Broadcom iproc-static-adc

2016-06-22 Thread Raveendra Padasalagi
This patch adds DT node for Broadcom's iproc-static-adc
controller driver.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
---
 arch/arm/boot/dts/bcm-cygnus.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi 
b/arch/arm/boot/dts/bcm-cygnus.dtsi
index b42fe55..fabc9f3 100644
--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
+++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
@@ -366,5 +366,16 @@
interrupts = ;
status = "disabled";
};
+
+   adc: adc@180a6000 {
+   compatible = "brcm,iproc-static-adc";
+   #io-channel-cells = <1>;
+   io-channel-ranges;
+   adc-syscon = <_adc_syscon>;
+   clocks = <_clks BCM_CYGNUS_ASIU_ADC_CLK>;
+   clock-names = "tsc_clk";
+   interrupts = ;
+   status = "disabled";
+   };
};
 };
-- 
1.9.1



[PATCH v3 3/3] ARM:dts-Add dt node for Broadcom iproc-static-adc

2016-06-22 Thread Raveendra Padasalagi
This patch adds DT node for Broadcom's iproc-static-adc
controller driver.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 arch/arm/boot/dts/bcm-cygnus.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi 
b/arch/arm/boot/dts/bcm-cygnus.dtsi
index b42fe55..fabc9f3 100644
--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
+++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
@@ -366,5 +366,16 @@
interrupts = ;
status = "disabled";
};
+
+   adc: adc@180a6000 {
+   compatible = "brcm,iproc-static-adc";
+   #io-channel-cells = <1>;
+   io-channel-ranges;
+   adc-syscon = <_adc_syscon>;
+   clocks = <_clks BCM_CYGNUS_ASIU_ADC_CLK>;
+   clock-names = "tsc_clk";
+   interrupts = ;
+   status = "disabled";
+   };
};
 };
-- 
1.9.1



[PATCH v3 0/3] Add Broadcom iproc-static-adc controller driver

2016-06-22 Thread Raveendra Padasalagi
This patchset contains initial driver for Broadcom's
iproc static adc controller. The patchset is based on v4.7-rc1
tag and its tested on Broadcom Cygnus SoC.

The patches can be fetched from iproc-adc-v3 branch of
https://github.com/Broadcom/arm64-linux.git

Changes since v2:
 - Addressed various comments given by Jonathan Cameron and
   Peter Meerwald-Stadler on driver source code related to linux
   coding style and clean-up of code. Lot of source code change
   happened especially due to redefining the #defines.
 - Added code to support IIO_CHAN_INFO_SCALE mask to return
   scale value in iproc_adc_read_raw().
 - Removed #address-cells, #size-cells properties in DT binding
   document and dts file as adc will not have any child nodes as
   noticed by Rob Herring.

Changes since v1:
 - Modified Kconfig file to add more informative information
   in Broadcom Adc driver configuration menu.
 - Added Broadcom Adc driver menu config in the alphabetical
   order in Kconfig
 - Addressed various comments given by Peter Meerwald-Stadler
   on driver source code, Including issues related to linux
   coding style and race conditions.

Raveendra Padasalagi (3):
  Documentation: DT: Add iproc-static-adc binding
  iio: Add driver for Broadcom iproc-static-adc
  ARM:dts-Add dt node for Broadcom iproc-static-adc

 .../bindings/iio/adc/brcm,iproc-static-adc.txt |  38 ++
 arch/arm/boot/dts/bcm-cygnus.dtsi  |  11 +
 drivers/iio/adc/Kconfig|  12 +
 drivers/iio/adc/Makefile   |   1 +
 drivers/iio/adc/bcm_iproc_adc.c| 648 +
 5 files changed, 710 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
 create mode 100644 drivers/iio/adc/bcm_iproc_adc.c

-- 
1.9.1



[PATCH v3 2/3] iio: Add driver for Broadcom iproc-static-adc

2016-06-22 Thread Raveendra Padasalagi
This patch adds basic driver implementation for Broadcom's
static adc controller used in iProc SoC's family.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
---
 drivers/iio/adc/Kconfig |  12 +
 drivers/iio/adc/Makefile|   1 +
 drivers/iio/adc/bcm_iproc_adc.c | 648 
 3 files changed, 661 insertions(+)
 create mode 100644 drivers/iio/adc/bcm_iproc_adc.c

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 25378c5..1de31bd 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -153,6 +153,18 @@ config AXP288_ADC
  To compile this driver as a module, choose M here: the module will be
  called axp288_adc.
 
+config BCM_IPROC_ADC
+   tristate "Broadcom IPROC ADC driver"
+   depends on ARCH_BCM_IPROC || COMPILE_TEST
+   depends on MFD_SYSCON
+   default ARCH_BCM_CYGNUS
+   help
+ Say Y here if you want to add support for the Broadcom static
+ ADC driver.
+
+ Broadcom iProc ADC driver. Broadcom iProc ADC controller has 8
+ channels. The driver allows the user to read voltage values.
+
 config BERLIN2_ADC
tristate "Marvell Berlin2 ADC driver"
depends on ARCH_BERLIN
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index 38638d4..0ba0d50 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_AD799X) += ad799x.o
 obj-$(CONFIG_AT91_ADC) += at91_adc.o
 obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o
 obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
+obj-$(CONFIG_BCM_IPROC_ADC) += bcm_iproc_adc.o
 obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
 obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
 obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o
diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
new file mode 100644
index 000..e10f6ce
--- /dev/null
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -0,0 +1,648 @@
+/*
+ * Copyright 2016 Broadcom
+ *
+ * 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 (the "GPL").
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 (GPLv2) for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 (GPLv2) along with this source code.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/* Below Register's are common to IPROC ADC and Touchscreen IP */
+#define IPROC_REGCTL1  0x00
+#define IPROC_REGCTL2  0x04
+#define IPROC_INTERRUPT_THRES  0x08
+#define IPROC_INTERRUPT_MASK   0x0c
+#define IPROC_INTERRUPT_STATUS 0x10
+#define IPROC_ANALOG_CONTROL   0x1c
+#define IPROC_CONTROLLER_STATUS0x14
+#define IPROC_AUX_DATA 0x20
+#define IPROC_SOFT_BYPASS_CONTROL  0x38
+#define IPROC_SOFT_BYPASS_DATA 0x3C
+
+/* IPROC ADC Channel register offsets */
+#define IPROC_ADC_CHANNEL_REGCTL1  0x800
+#define IPROC_ADC_CHANNEL_REGCTL2  0x804
+#define IPROC_ADC_CHANNEL_STATUS   0x808
+#define IPROC_ADC_CHANNEL_INTERRUPT_STATUS 0x80c
+#define IPROC_ADC_CHANNEL_INTERRUPT_MASK   0x810
+#define IPROC_ADC_CHANNEL_DATA 0x814
+#define IPROC_ADC_CHANNEL_OFFSET   0x20
+
+/* Bit definitions for IPROC_REGCTL2 */
+#define IPROC_ADC_AUXIN_SCAN_ENA   BIT(0)
+#define IPROC_ADC_PWR_LDO  BIT(5)
+#define IPROC_ADC_PWR_ADC  BIT(4)
+#define IPROC_ADC_PWR_BG   BIT(3)
+#define IPROC_ADC_CONTROLLER_ENBIT(17)
+
+/* Bit definitions for IPROC_INTERRUPT_MASK and IPROC_INTERRUPT_STATUS */
+#define IPROC_ADC_AUXDATA_RDY_INTR BIT(3)
+#define IPROC_ADC_INTR 9
+#define IPROC_ADC_INTR_MASK(0xFF << IPROC_ADC_INTR)
+
+/* Bit definitions for IPROC_ANALOG_CONTROL */
+#define IPROC_ADC_CHANNEL_SEL  11
+#define IPROC_ADC_CHANNEL_SEL_MASK (0x7 << IPROC_ADC_CHANNEL_SEL)
+
+/* Bit definitions for IPROC_ADC_CHANNEL_REGCTL1 */
+#define IPROC_ADC_CHANNEL_ROUNDS   0x2
+#define IPROC_ADC_CHANNEL_ROUNDS_MASK  (0x3F << IPROC_ADC_CHANNEL_ROUNDS)
+#define IPROC_ADC_CHANNEL_MODE 0x1
+#define IPROC_ADC_CHANNEL_MODE_MASK(0x1 << IPROC_ADC_CHANNEL_MODE)
+#define IPROC_ADC_CHANNEL_MODE_TDM 0x1
+#define IPROC_ADC_CHANNEL_MODE_SNAPSHOT 0x0
+#define IPROC_ADC_CHANNEL_ENABLE   0x0
+#define IPROC_ADC_CHAN

[PATCH v3 0/3] Add Broadcom iproc-static-adc controller driver

2016-06-22 Thread Raveendra Padasalagi
This patchset contains initial driver for Broadcom's
iproc static adc controller. The patchset is based on v4.7-rc1
tag and its tested on Broadcom Cygnus SoC.

The patches can be fetched from iproc-adc-v3 branch of
https://github.com/Broadcom/arm64-linux.git

Changes since v2:
 - Addressed various comments given by Jonathan Cameron and
   Peter Meerwald-Stadler on driver source code related to linux
   coding style and clean-up of code. Lot of source code change
   happened especially due to redefining the #defines.
 - Added code to support IIO_CHAN_INFO_SCALE mask to return
   scale value in iproc_adc_read_raw().
 - Removed #address-cells, #size-cells properties in DT binding
   document and dts file as adc will not have any child nodes as
   noticed by Rob Herring.

Changes since v1:
 - Modified Kconfig file to add more informative information
   in Broadcom Adc driver configuration menu.
 - Added Broadcom Adc driver menu config in the alphabetical
   order in Kconfig
 - Addressed various comments given by Peter Meerwald-Stadler
   on driver source code, Including issues related to linux
   coding style and race conditions.

Raveendra Padasalagi (3):
  Documentation: DT: Add iproc-static-adc binding
  iio: Add driver for Broadcom iproc-static-adc
  ARM:dts-Add dt node for Broadcom iproc-static-adc

 .../bindings/iio/adc/brcm,iproc-static-adc.txt |  38 ++
 arch/arm/boot/dts/bcm-cygnus.dtsi  |  11 +
 drivers/iio/adc/Kconfig|  12 +
 drivers/iio/adc/Makefile   |   1 +
 drivers/iio/adc/bcm_iproc_adc.c| 648 +
 5 files changed, 710 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
 create mode 100644 drivers/iio/adc/bcm_iproc_adc.c

-- 
1.9.1



[PATCH v3 2/3] iio: Add driver for Broadcom iproc-static-adc

2016-06-22 Thread Raveendra Padasalagi
This patch adds basic driver implementation for Broadcom's
static adc controller used in iProc SoC's family.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 drivers/iio/adc/Kconfig |  12 +
 drivers/iio/adc/Makefile|   1 +
 drivers/iio/adc/bcm_iproc_adc.c | 648 
 3 files changed, 661 insertions(+)
 create mode 100644 drivers/iio/adc/bcm_iproc_adc.c

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 25378c5..1de31bd 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -153,6 +153,18 @@ config AXP288_ADC
  To compile this driver as a module, choose M here: the module will be
  called axp288_adc.
 
+config BCM_IPROC_ADC
+   tristate "Broadcom IPROC ADC driver"
+   depends on ARCH_BCM_IPROC || COMPILE_TEST
+   depends on MFD_SYSCON
+   default ARCH_BCM_CYGNUS
+   help
+ Say Y here if you want to add support for the Broadcom static
+ ADC driver.
+
+ Broadcom iProc ADC driver. Broadcom iProc ADC controller has 8
+ channels. The driver allows the user to read voltage values.
+
 config BERLIN2_ADC
tristate "Marvell Berlin2 ADC driver"
depends on ARCH_BERLIN
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index 38638d4..0ba0d50 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_AD799X) += ad799x.o
 obj-$(CONFIG_AT91_ADC) += at91_adc.o
 obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o
 obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
+obj-$(CONFIG_BCM_IPROC_ADC) += bcm_iproc_adc.o
 obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
 obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
 obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o
diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
new file mode 100644
index 000..e10f6ce
--- /dev/null
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -0,0 +1,648 @@
+/*
+ * Copyright 2016 Broadcom
+ *
+ * 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 (the "GPL").
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 (GPLv2) for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 (GPLv2) along with this source code.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/* Below Register's are common to IPROC ADC and Touchscreen IP */
+#define IPROC_REGCTL1  0x00
+#define IPROC_REGCTL2  0x04
+#define IPROC_INTERRUPT_THRES  0x08
+#define IPROC_INTERRUPT_MASK   0x0c
+#define IPROC_INTERRUPT_STATUS 0x10
+#define IPROC_ANALOG_CONTROL   0x1c
+#define IPROC_CONTROLLER_STATUS0x14
+#define IPROC_AUX_DATA 0x20
+#define IPROC_SOFT_BYPASS_CONTROL  0x38
+#define IPROC_SOFT_BYPASS_DATA 0x3C
+
+/* IPROC ADC Channel register offsets */
+#define IPROC_ADC_CHANNEL_REGCTL1  0x800
+#define IPROC_ADC_CHANNEL_REGCTL2  0x804
+#define IPROC_ADC_CHANNEL_STATUS   0x808
+#define IPROC_ADC_CHANNEL_INTERRUPT_STATUS 0x80c
+#define IPROC_ADC_CHANNEL_INTERRUPT_MASK   0x810
+#define IPROC_ADC_CHANNEL_DATA 0x814
+#define IPROC_ADC_CHANNEL_OFFSET   0x20
+
+/* Bit definitions for IPROC_REGCTL2 */
+#define IPROC_ADC_AUXIN_SCAN_ENA   BIT(0)
+#define IPROC_ADC_PWR_LDO  BIT(5)
+#define IPROC_ADC_PWR_ADC  BIT(4)
+#define IPROC_ADC_PWR_BG   BIT(3)
+#define IPROC_ADC_CONTROLLER_ENBIT(17)
+
+/* Bit definitions for IPROC_INTERRUPT_MASK and IPROC_INTERRUPT_STATUS */
+#define IPROC_ADC_AUXDATA_RDY_INTR BIT(3)
+#define IPROC_ADC_INTR 9
+#define IPROC_ADC_INTR_MASK(0xFF << IPROC_ADC_INTR)
+
+/* Bit definitions for IPROC_ANALOG_CONTROL */
+#define IPROC_ADC_CHANNEL_SEL  11
+#define IPROC_ADC_CHANNEL_SEL_MASK (0x7 << IPROC_ADC_CHANNEL_SEL)
+
+/* Bit definitions for IPROC_ADC_CHANNEL_REGCTL1 */
+#define IPROC_ADC_CHANNEL_ROUNDS   0x2
+#define IPROC_ADC_CHANNEL_ROUNDS_MASK  (0x3F << IPROC_ADC_CHANNEL_ROUNDS)
+#define IPROC_ADC_CHANNEL_MODE 0x1
+#define IPROC_ADC_CHANNEL_MODE_MASK(0x1 << IPROC_ADC_CHANNEL_MODE)
+#define IPROC_ADC_CHANNEL_MODE_TDM 0x1
+#define IPROC_ADC_CHANNEL_MODE_SNAPSHOT 0x0
+#define IPROC_ADC_CHANNEL_ENABLE   0x0
+#define IPROC_ADC_CHANNEL_ENABLE_MASK  0x1
+
+/* Bit definitions for IPROC_ADC_CHANNEL_REGCTL2 */
+#define IPROC_ADC_CHANNEL_WATE

[PATCH v3 1/3] Documentation: DT: Add iproc-static-adc binding

2016-06-22 Thread Raveendra Padasalagi
The patch adds devicetree binding document for broadcom's
iproc-static-adc controller driver.

Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
Reviewed-by: Ray Jui <ray@broadcom.com>
Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
---
 .../bindings/iio/adc/brcm,iproc-static-adc.txt | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt

diff --git 
a/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt 
b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
new file mode 100644
index 000..a82076e
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
@@ -0,0 +1,38 @@
+* Broadcom's IPROC Static ADC controller
+
+Broadcom iProc ADC controller has 8 channels 10bit ADC.
+Allows user to convert analog input voltage values to digital.
+
+Required properties:
+
+- compatible: Must be "brcm,iproc-static-adc"
+
+- adc-syscon: Handler of syscon node defining physical base address of the
+  controller and length of memory mapped region.
+
+- #io-channel-cells = <1>; As ADC has multiple outputs
+  refer to Documentation/devicetree/bindings/iio/iio-bindings.txt for details.
+
+- clocks: Clock used for this block.
+
+- clock-names: Clock name should be given as tsc_clk.
+
+- interrupts: interrupt line number.
+
+For example:
+
+   ts_adc_syscon: ts_adc_syscon@180a6000 {
+   compatible = "brcm,iproc-ts-adc-syscon","syscon";
+   reg = <0x180a6000 0xc30>;
+   };
+
+   adc: adc@180a6000 {
+   compatible = "brcm,iproc-static-adc";
+   adc-syscon = <_adc_syscon>;
+   #io-channel-cells = <1>;
+   io-channel-ranges;
+   clocks = <_clks BCM_CYGNUS_ASIU_ADC_CLK>;
+   clock-names = "tsc_clk";
+   interrupts = ;
+   status = "disabled";
+   };
-- 
1.9.1



[PATCH v3 1/3] Documentation: DT: Add iproc-static-adc binding

2016-06-22 Thread Raveendra Padasalagi
The patch adds devicetree binding document for broadcom's
iproc-static-adc controller driver.

Signed-off-by: Raveendra Padasalagi 
Reviewed-by: Ray Jui 
Reviewed-by: Scott Branden 
---
 .../bindings/iio/adc/brcm,iproc-static-adc.txt | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt

diff --git 
a/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt 
b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
new file mode 100644
index 000..a82076e
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt
@@ -0,0 +1,38 @@
+* Broadcom's IPROC Static ADC controller
+
+Broadcom iProc ADC controller has 8 channels 10bit ADC.
+Allows user to convert analog input voltage values to digital.
+
+Required properties:
+
+- compatible: Must be "brcm,iproc-static-adc"
+
+- adc-syscon: Handler of syscon node defining physical base address of the
+  controller and length of memory mapped region.
+
+- #io-channel-cells = <1>; As ADC has multiple outputs
+  refer to Documentation/devicetree/bindings/iio/iio-bindings.txt for details.
+
+- clocks: Clock used for this block.
+
+- clock-names: Clock name should be given as tsc_clk.
+
+- interrupts: interrupt line number.
+
+For example:
+
+   ts_adc_syscon: ts_adc_syscon@180a6000 {
+   compatible = "brcm,iproc-ts-adc-syscon","syscon";
+   reg = <0x180a6000 0xc30>;
+   };
+
+   adc: adc@180a6000 {
+   compatible = "brcm,iproc-static-adc";
+   adc-syscon = <_adc_syscon>;
+   #io-channel-cells = <1>;
+   io-channel-ranges;
+   clocks = <_clks BCM_CYGNUS_ASIU_ADC_CLK>;
+   clock-names = "tsc_clk";
+   interrupts = ;
+   status = "disabled";
+   };
-- 
1.9.1



Re: [PATCH v2 2/3] iio: Add driver for Broadcom iproc-static-adc

2016-06-21 Thread Raveendra Padasalagi
Hi Jonathan,

Thanks for the review comments. I will address these in the next patch.
Please find my reply inline.

Regards,
Raveendra

On Mon, Jun 20, 2016 at 1:05 AM, Jonathan Cameron <ji...@kernel.org> wrote:
> On 19/06/16 11:06, Raveendra Padasalagi wrote:
>> This patch adds basic driver implementation for Broadcom's
>> static adc controller used in iProc SoC's family.
>>
>> Signed-off-by: Raveendra Padasalagi <raveendra.padasal...@broadcom.com>
>> Reviewed-by: Ray Jui <ray@broadcom.com>
>> Reviewed-by: Scott Branden <scott.bran...@broadcom.com>
> Hi All,
>
> The inconvenience of lunch and an afternoon of gardening occured in the
> middle of this review, so much of what I have may well have been covered
> by Peter!
>
> Anyhow, various bits inline.  In particular, there is very little handling
> of potential regmap functions returning errors in here.  I know they are
> pretty unlikely, but I think it would be nice to handle them anyway.
>
> Interesting bit of kit so I hope you have the oportunity to look at fuller
> support of those fifos. Any public info on the part in question?

Currently details of ADC controller is not publicly available. Yes, I
have plan for
improving this driver to make use of fifo's in the next step, This ADC has
a continuous capture mode feature.

> Thanks
>
> Jonathan
>> ---
>>  drivers/iio/adc/Kconfig |  13 +
>>  drivers/iio/adc/Makefile|   1 +
>>  drivers/iio/adc/bcm_iproc_adc.c | 563 
>> 
>>  3 files changed, 577 insertions(+)
>>  create mode 100644 drivers/iio/adc/bcm_iproc_adc.c
>>
>> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>> index 25378c5..195dcd4 100644
>> --- a/drivers/iio/adc/Kconfig
>> +++ b/drivers/iio/adc/Kconfig
>> @@ -153,6 +153,19 @@ config AXP288_ADC
>> To compile this driver as a module, choose M here: the module will be
>> called axp288_adc.
>>
>> +config BCM_IPROC_ADC
>> + tristate "Broadcom IPROC ADC driver"
>> + depends on ARCH_BCM_IPROC || COMPILE_TEST
>> + depends on MFD_SYSCON
>> + default ARCH_BCM_CYGNUS
>> + help
>> +   Say Y here if you want to add support for the Broadcom static
>> +   ADC driver.
>> +
>> +   Broadcom iProc ADC driver. Broadcom iProc ADC controller has 8
>> +   channels. The driver allows the user to read voltage and
>> +   temperature values.
>> +
>>  config BERLIN2_ADC
>>   tristate "Marvell Berlin2 ADC driver"
>>   depends on ARCH_BERLIN
>> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
>> index 38638d4..0ba0d50 100644
>> --- a/drivers/iio/adc/Makefile
>> +++ b/drivers/iio/adc/Makefile
>> @@ -16,6 +16,7 @@ obj-$(CONFIG_AD799X) += ad799x.o
>>  obj-$(CONFIG_AT91_ADC) += at91_adc.o
>>  obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o
>>  obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
>> +obj-$(CONFIG_BCM_IPROC_ADC) += bcm_iproc_adc.o
>>  obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
>>  obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
>>  obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o
>> diff --git a/drivers/iio/adc/bcm_iproc_adc.c 
>> b/drivers/iio/adc/bcm_iproc_adc.c
>> new file mode 100644
>> index 000..6bfc160
>> --- /dev/null
>> +++ b/drivers/iio/adc/bcm_iproc_adc.c
>> @@ -0,0 +1,563 @@
>> +/*
>> + * Copyright 2016 Broadcom
>> + *
>> + * 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 (the "GPL").
>> + *
>> + * This program is distributed in the hope that it will be useful, but
>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * General Public License version 2 (GPLv2) for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * version 2 (GPLv2) along with this source code.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
> Why?  Not immediately seeing any use of iio_maps in here...

Yes, we don't need iio_maps.will remove it in the next patch.

>> +#include 
> snap.
>> +
>> +#define IPROC_ADC_READ_TIMEOUT(HZ*2)
>> +
>> +/* Register offset

Re: [PATCH v2 2/3] iio: Add driver for Broadcom iproc-static-adc

2016-06-21 Thread Raveendra Padasalagi
Hi Jonathan,

Thanks for the review comments. I will address these in the next patch.
Please find my reply inline.

Regards,
Raveendra

On Mon, Jun 20, 2016 at 1:05 AM, Jonathan Cameron  wrote:
> On 19/06/16 11:06, Raveendra Padasalagi wrote:
>> This patch adds basic driver implementation for Broadcom's
>> static adc controller used in iProc SoC's family.
>>
>> Signed-off-by: Raveendra Padasalagi 
>> Reviewed-by: Ray Jui 
>> Reviewed-by: Scott Branden 
> Hi All,
>
> The inconvenience of lunch and an afternoon of gardening occured in the
> middle of this review, so much of what I have may well have been covered
> by Peter!
>
> Anyhow, various bits inline.  In particular, there is very little handling
> of potential regmap functions returning errors in here.  I know they are
> pretty unlikely, but I think it would be nice to handle them anyway.
>
> Interesting bit of kit so I hope you have the oportunity to look at fuller
> support of those fifos. Any public info on the part in question?

Currently details of ADC controller is not publicly available. Yes, I
have plan for
improving this driver to make use of fifo's in the next step, This ADC has
a continuous capture mode feature.

> Thanks
>
> Jonathan
>> ---
>>  drivers/iio/adc/Kconfig |  13 +
>>  drivers/iio/adc/Makefile|   1 +
>>  drivers/iio/adc/bcm_iproc_adc.c | 563 
>> 
>>  3 files changed, 577 insertions(+)
>>  create mode 100644 drivers/iio/adc/bcm_iproc_adc.c
>>
>> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>> index 25378c5..195dcd4 100644
>> --- a/drivers/iio/adc/Kconfig
>> +++ b/drivers/iio/adc/Kconfig
>> @@ -153,6 +153,19 @@ config AXP288_ADC
>> To compile this driver as a module, choose M here: the module will be
>> called axp288_adc.
>>
>> +config BCM_IPROC_ADC
>> + tristate "Broadcom IPROC ADC driver"
>> + depends on ARCH_BCM_IPROC || COMPILE_TEST
>> + depends on MFD_SYSCON
>> + default ARCH_BCM_CYGNUS
>> + help
>> +   Say Y here if you want to add support for the Broadcom static
>> +   ADC driver.
>> +
>> +   Broadcom iProc ADC driver. Broadcom iProc ADC controller has 8
>> +   channels. The driver allows the user to read voltage and
>> +   temperature values.
>> +
>>  config BERLIN2_ADC
>>   tristate "Marvell Berlin2 ADC driver"
>>   depends on ARCH_BERLIN
>> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
>> index 38638d4..0ba0d50 100644
>> --- a/drivers/iio/adc/Makefile
>> +++ b/drivers/iio/adc/Makefile
>> @@ -16,6 +16,7 @@ obj-$(CONFIG_AD799X) += ad799x.o
>>  obj-$(CONFIG_AT91_ADC) += at91_adc.o
>>  obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o
>>  obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
>> +obj-$(CONFIG_BCM_IPROC_ADC) += bcm_iproc_adc.o
>>  obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
>>  obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
>>  obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o
>> diff --git a/drivers/iio/adc/bcm_iproc_adc.c 
>> b/drivers/iio/adc/bcm_iproc_adc.c
>> new file mode 100644
>> index 000..6bfc160
>> --- /dev/null
>> +++ b/drivers/iio/adc/bcm_iproc_adc.c
>> @@ -0,0 +1,563 @@
>> +/*
>> + * Copyright 2016 Broadcom
>> + *
>> + * 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 (the "GPL").
>> + *
>> + * This program is distributed in the hope that it will be useful, but
>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * General Public License version 2 (GPLv2) for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * version 2 (GPLv2) along with this source code.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
> Why?  Not immediately seeing any use of iio_maps in here...

Yes, we don't need iio_maps.will remove it in the next patch.

>> +#include 
> snap.
>> +
>> +#define IPROC_ADC_READ_TIMEOUT(HZ*2)
>> +
>> +/* Register offsets */
>> +#define REGCTL1  0x00
>> +#define REGCTL2  0x04
>&

  1   2   3   >