Re: [U-Boot] [PATCH 1/2] drivers: USB: OHCI: allow compilation for 64-bit targets

2016-10-26 Thread Jagan Teki
On Tue, Oct 25, 2016 at 4:16 AM, André Przywara  wrote:
> On 24/10/16 09:20, Jagan Teki wrote:
>> On Sun, Oct 23, 2016 at 3:22 AM, André Przywara  
>> wrote:
>>> On 22/10/16 18:10, Jagan Teki wrote:
>>>
>>> Hi,
>>>
 On Fri, Oct 21, 2016 at 6:54 AM, Andre Przywara  
 wrote:
> OHCI has a known limitation of allowing only 32-bit DMA buffer
> addresses, so we have a lot of u32 variables around, which are assigned
> to pointers and vice versa. This obviously creates issues with 64-bit
> systems, so the compiler complains here and there.
> To allow compilation for 64-bit boards which use only memory below 4GB
> anyway (and to avoid more invasive fixes), adjust some casts and types
> and assume that the EDs and TDs are all located in the lower 4GB.
> This fixes compilation of the OHCI driver for the Pine64.
>
> Signed-off-by: Andre Przywara 
> ---
>  drivers/usb/host/ohci-hcd.c   | 21 +++--
>  drivers/usb/host/ohci-sunxi.c |  2 +-
>  drivers/usb/host/ohci.h   | 11 +++
>  3 files changed, 19 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
> index ccbfc02..0f6d03e 100644
> --- a/drivers/usb/host/ohci-hcd.c
> +++ b/drivers/usb/host/ohci-hcd.c
> @@ -682,7 +682,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
> ed->hwNextED = 0;
> flush_dcache_ed(ed);
> if (ohci->ed_controltail == NULL)
> -   ohci_writel(ed, >regs->ed_controlhead);
> +   ohci_writel((uintptr_t)ed, 
> >regs->ed_controlhead);
> else
> ohci->ed_controltail->hwNextED =
>m32_swap((unsigned 
> long)ed);
> @@ -700,7 +700,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
> ed->hwNextED = 0;
> flush_dcache_ed(ed);
> if (ohci->ed_bulktail == NULL)
> -   ohci_writel(ed, >regs->ed_bulkhead);
> +   ohci_writel((uintptr_t)ed, 
> >regs->ed_bulkhead);
> else
> ohci->ed_bulktail->hwNextED =
>m32_swap((unsigned 
> long)ed);
> @@ -753,7 +753,7 @@ static void periodic_unlink(struct ohci *ohci, 
> volatile struct ed *ed,
>
> /* ED might have been unlinked through another path */
> while (*ed_p != 0) {
> -   if (((struct ed *)
> +   if (((struct ed *)(uintptr_t)
> m32_swap((unsigned long)ed_p)) == 
> ed) {
> *ed_p = ed->hwNextED;
> aligned_ed_p = (unsigned long)ed_p;
> @@ -762,7 +762,7 @@ static void periodic_unlink(struct ohci *ohci, 
> volatile struct ed *ed,
> aligned_ed_p + ARCH_DMA_MINALIGN);
> break;
> }
> -   ed_p = &(((struct ed *)
> +   ed_p = &(((struct ed *)(uintptr_t)
>  m32_swap((unsigned 
> long)ed_p))->hwNextED);
> }
> }
> @@ -798,7 +798,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
> if (ohci->ed_controltail == ed) {
> ohci->ed_controltail = ed->ed_prev;
> } else {
> -   ((ed_t *)m32_swap(
> +   ((ed_t *)(uintptr_t)m32_swap(
> *((__u32 *)>hwNextED)))->ed_prev = 
> ed->ed_prev;
> }
> break;
> @@ -819,7 +819,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
> if (ohci->ed_bulktail == ed) {
> ohci->ed_bulktail = ed->ed_prev;
> } else {
> -   ((ed_t *)m32_swap(
> +   ((ed_t *)(uintptr_t)m32_swap(
>  *((__u32 *)>hwNextED)))->ed_prev = 
> ed->ed_prev;
> }
> break;
> @@ -914,12 +914,13 @@ static void td_fill(ohci_t *ohci, unsigned int info,
>
> /* fill the old dummy TD */
> td = urb_priv->td [index] =
> -(td_t *)(m32_swap(urb_priv->ed->hwTailP) & 
> ~0xf);
> +(td_t *)(uintptr_t)
> +(m32_swap(urb_priv->ed->hwTailP) & ~0xf);
>
> td->ed = urb_priv->ed;
> 

Re: [U-Boot] [PATCH 1/2] drivers: USB: OHCI: allow compilation for 64-bit targets

2016-10-24 Thread André Przywara
On 24/10/16 09:20, Jagan Teki wrote:
> On Sun, Oct 23, 2016 at 3:22 AM, André Przywara  
> wrote:
>> On 22/10/16 18:10, Jagan Teki wrote:
>>
>> Hi,
>>
>>> On Fri, Oct 21, 2016 at 6:54 AM, Andre Przywara  
>>> wrote:
 OHCI has a known limitation of allowing only 32-bit DMA buffer
 addresses, so we have a lot of u32 variables around, which are assigned
 to pointers and vice versa. This obviously creates issues with 64-bit
 systems, so the compiler complains here and there.
 To allow compilation for 64-bit boards which use only memory below 4GB
 anyway (and to avoid more invasive fixes), adjust some casts and types
 and assume that the EDs and TDs are all located in the lower 4GB.
 This fixes compilation of the OHCI driver for the Pine64.

 Signed-off-by: Andre Przywara 
 ---
  drivers/usb/host/ohci-hcd.c   | 21 +++--
  drivers/usb/host/ohci-sunxi.c |  2 +-
  drivers/usb/host/ohci.h   | 11 +++
  3 files changed, 19 insertions(+), 15 deletions(-)

 diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
 index ccbfc02..0f6d03e 100644
 --- a/drivers/usb/host/ohci-hcd.c
 +++ b/drivers/usb/host/ohci-hcd.c
 @@ -682,7 +682,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
 ed->hwNextED = 0;
 flush_dcache_ed(ed);
 if (ohci->ed_controltail == NULL)
 -   ohci_writel(ed, >regs->ed_controlhead);
 +   ohci_writel((uintptr_t)ed, 
 >regs->ed_controlhead);
 else
 ohci->ed_controltail->hwNextED =
m32_swap((unsigned 
 long)ed);
 @@ -700,7 +700,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
 ed->hwNextED = 0;
 flush_dcache_ed(ed);
 if (ohci->ed_bulktail == NULL)
 -   ohci_writel(ed, >regs->ed_bulkhead);
 +   ohci_writel((uintptr_t)ed, 
 >regs->ed_bulkhead);
 else
 ohci->ed_bulktail->hwNextED =
m32_swap((unsigned 
 long)ed);
 @@ -753,7 +753,7 @@ static void periodic_unlink(struct ohci *ohci, 
 volatile struct ed *ed,

 /* ED might have been unlinked through another path */
 while (*ed_p != 0) {
 -   if (((struct ed *)
 +   if (((struct ed *)(uintptr_t)
 m32_swap((unsigned long)ed_p)) == 
 ed) {
 *ed_p = ed->hwNextED;
 aligned_ed_p = (unsigned long)ed_p;
 @@ -762,7 +762,7 @@ static void periodic_unlink(struct ohci *ohci, 
 volatile struct ed *ed,
 aligned_ed_p + ARCH_DMA_MINALIGN);
 break;
 }
 -   ed_p = &(((struct ed *)
 +   ed_p = &(((struct ed *)(uintptr_t)
  m32_swap((unsigned 
 long)ed_p))->hwNextED);
 }
 }
 @@ -798,7 +798,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
 if (ohci->ed_controltail == ed) {
 ohci->ed_controltail = ed->ed_prev;
 } else {
 -   ((ed_t *)m32_swap(
 +   ((ed_t *)(uintptr_t)m32_swap(
 *((__u32 *)>hwNextED)))->ed_prev = 
 ed->ed_prev;
 }
 break;
 @@ -819,7 +819,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
 if (ohci->ed_bulktail == ed) {
 ohci->ed_bulktail = ed->ed_prev;
 } else {
 -   ((ed_t *)m32_swap(
 +   ((ed_t *)(uintptr_t)m32_swap(
  *((__u32 *)>hwNextED)))->ed_prev = 
 ed->ed_prev;
 }
 break;
 @@ -914,12 +914,13 @@ static void td_fill(ohci_t *ohci, unsigned int info,

 /* fill the old dummy TD */
 td = urb_priv->td [index] =
 -(td_t *)(m32_swap(urb_priv->ed->hwTailP) & 
 ~0xf);
 +(td_t *)(uintptr_t)
 +(m32_swap(urb_priv->ed->hwTailP) & ~0xf);

 td->ed = urb_priv->ed;
 td->next_dl_td = NULL;
 td->index = index;
 -   td->data = (__u32)data;
 +   td->data = (uintptr_t)data;
  #ifdef OHCI_FILL_TRACE
 if 

Re: [U-Boot] [PATCH 1/2] drivers: USB: OHCI: allow compilation for 64-bit targets

2016-10-24 Thread Jagan Teki
On Sun, Oct 23, 2016 at 3:22 AM, André Przywara  wrote:
> On 22/10/16 18:10, Jagan Teki wrote:
>
> Hi,
>
>> On Fri, Oct 21, 2016 at 6:54 AM, Andre Przywara  
>> wrote:
>>> OHCI has a known limitation of allowing only 32-bit DMA buffer
>>> addresses, so we have a lot of u32 variables around, which are assigned
>>> to pointers and vice versa. This obviously creates issues with 64-bit
>>> systems, so the compiler complains here and there.
>>> To allow compilation for 64-bit boards which use only memory below 4GB
>>> anyway (and to avoid more invasive fixes), adjust some casts and types
>>> and assume that the EDs and TDs are all located in the lower 4GB.
>>> This fixes compilation of the OHCI driver for the Pine64.
>>>
>>> Signed-off-by: Andre Przywara 
>>> ---
>>>  drivers/usb/host/ohci-hcd.c   | 21 +++--
>>>  drivers/usb/host/ohci-sunxi.c |  2 +-
>>>  drivers/usb/host/ohci.h   | 11 +++
>>>  3 files changed, 19 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
>>> index ccbfc02..0f6d03e 100644
>>> --- a/drivers/usb/host/ohci-hcd.c
>>> +++ b/drivers/usb/host/ohci-hcd.c
>>> @@ -682,7 +682,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
>>> ed->hwNextED = 0;
>>> flush_dcache_ed(ed);
>>> if (ohci->ed_controltail == NULL)
>>> -   ohci_writel(ed, >regs->ed_controlhead);
>>> +   ohci_writel((uintptr_t)ed, 
>>> >regs->ed_controlhead);
>>> else
>>> ohci->ed_controltail->hwNextED =
>>>m32_swap((unsigned 
>>> long)ed);
>>> @@ -700,7 +700,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
>>> ed->hwNextED = 0;
>>> flush_dcache_ed(ed);
>>> if (ohci->ed_bulktail == NULL)
>>> -   ohci_writel(ed, >regs->ed_bulkhead);
>>> +   ohci_writel((uintptr_t)ed, 
>>> >regs->ed_bulkhead);
>>> else
>>> ohci->ed_bulktail->hwNextED =
>>>m32_swap((unsigned 
>>> long)ed);
>>> @@ -753,7 +753,7 @@ static void periodic_unlink(struct ohci *ohci, volatile 
>>> struct ed *ed,
>>>
>>> /* ED might have been unlinked through another path */
>>> while (*ed_p != 0) {
>>> -   if (((struct ed *)
>>> +   if (((struct ed *)(uintptr_t)
>>> m32_swap((unsigned long)ed_p)) == 
>>> ed) {
>>> *ed_p = ed->hwNextED;
>>> aligned_ed_p = (unsigned long)ed_p;
>>> @@ -762,7 +762,7 @@ static void periodic_unlink(struct ohci *ohci, volatile 
>>> struct ed *ed,
>>> aligned_ed_p + ARCH_DMA_MINALIGN);
>>> break;
>>> }
>>> -   ed_p = &(((struct ed *)
>>> +   ed_p = &(((struct ed *)(uintptr_t)
>>>  m32_swap((unsigned 
>>> long)ed_p))->hwNextED);
>>> }
>>> }
>>> @@ -798,7 +798,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
>>> if (ohci->ed_controltail == ed) {
>>> ohci->ed_controltail = ed->ed_prev;
>>> } else {
>>> -   ((ed_t *)m32_swap(
>>> +   ((ed_t *)(uintptr_t)m32_swap(
>>> *((__u32 *)>hwNextED)))->ed_prev = 
>>> ed->ed_prev;
>>> }
>>> break;
>>> @@ -819,7 +819,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
>>> if (ohci->ed_bulktail == ed) {
>>> ohci->ed_bulktail = ed->ed_prev;
>>> } else {
>>> -   ((ed_t *)m32_swap(
>>> +   ((ed_t *)(uintptr_t)m32_swap(
>>>  *((__u32 *)>hwNextED)))->ed_prev = 
>>> ed->ed_prev;
>>> }
>>> break;
>>> @@ -914,12 +914,13 @@ static void td_fill(ohci_t *ohci, unsigned int info,
>>>
>>> /* fill the old dummy TD */
>>> td = urb_priv->td [index] =
>>> -(td_t *)(m32_swap(urb_priv->ed->hwTailP) & 
>>> ~0xf);
>>> +(td_t *)(uintptr_t)
>>> +(m32_swap(urb_priv->ed->hwTailP) & ~0xf);
>>>
>>> td->ed = urb_priv->ed;
>>> td->next_dl_td = NULL;
>>> td->index = index;
>>> -   td->data = (__u32)data;
>>> +   td->data = (uintptr_t)data;
>>>  #ifdef OHCI_FILL_TRACE
>>> if (usb_pipebulk(urb_priv->pipe) && usb_pipeout(urb_priv->pipe)) {
>>> for (i = 0; i < len; i++)
>>> @@ -1099,7 +1100,7 @@ static void check_status(td_t 

Re: [U-Boot] [PATCH 1/2] drivers: USB: OHCI: allow compilation for 64-bit targets

2016-10-22 Thread André Przywara
On 22/10/16 18:10, Jagan Teki wrote:

Hi,

> On Fri, Oct 21, 2016 at 6:54 AM, Andre Przywara  
> wrote:
>> OHCI has a known limitation of allowing only 32-bit DMA buffer
>> addresses, so we have a lot of u32 variables around, which are assigned
>> to pointers and vice versa. This obviously creates issues with 64-bit
>> systems, so the compiler complains here and there.
>> To allow compilation for 64-bit boards which use only memory below 4GB
>> anyway (and to avoid more invasive fixes), adjust some casts and types
>> and assume that the EDs and TDs are all located in the lower 4GB.
>> This fixes compilation of the OHCI driver for the Pine64.
>>
>> Signed-off-by: Andre Przywara 
>> ---
>>  drivers/usb/host/ohci-hcd.c   | 21 +++--
>>  drivers/usb/host/ohci-sunxi.c |  2 +-
>>  drivers/usb/host/ohci.h   | 11 +++
>>  3 files changed, 19 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
>> index ccbfc02..0f6d03e 100644
>> --- a/drivers/usb/host/ohci-hcd.c
>> +++ b/drivers/usb/host/ohci-hcd.c
>> @@ -682,7 +682,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
>> ed->hwNextED = 0;
>> flush_dcache_ed(ed);
>> if (ohci->ed_controltail == NULL)
>> -   ohci_writel(ed, >regs->ed_controlhead);
>> +   ohci_writel((uintptr_t)ed, 
>> >regs->ed_controlhead);
>> else
>> ohci->ed_controltail->hwNextED =
>>m32_swap((unsigned 
>> long)ed);
>> @@ -700,7 +700,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
>> ed->hwNextED = 0;
>> flush_dcache_ed(ed);
>> if (ohci->ed_bulktail == NULL)
>> -   ohci_writel(ed, >regs->ed_bulkhead);
>> +   ohci_writel((uintptr_t)ed, >regs->ed_bulkhead);
>> else
>> ohci->ed_bulktail->hwNextED =
>>m32_swap((unsigned 
>> long)ed);
>> @@ -753,7 +753,7 @@ static void periodic_unlink(struct ohci *ohci, volatile 
>> struct ed *ed,
>>
>> /* ED might have been unlinked through another path */
>> while (*ed_p != 0) {
>> -   if (((struct ed *)
>> +   if (((struct ed *)(uintptr_t)
>> m32_swap((unsigned long)ed_p)) == 
>> ed) {
>> *ed_p = ed->hwNextED;
>> aligned_ed_p = (unsigned long)ed_p;
>> @@ -762,7 +762,7 @@ static void periodic_unlink(struct ohci *ohci, volatile 
>> struct ed *ed,
>> aligned_ed_p + ARCH_DMA_MINALIGN);
>> break;
>> }
>> -   ed_p = &(((struct ed *)
>> +   ed_p = &(((struct ed *)(uintptr_t)
>>  m32_swap((unsigned 
>> long)ed_p))->hwNextED);
>> }
>> }
>> @@ -798,7 +798,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
>> if (ohci->ed_controltail == ed) {
>> ohci->ed_controltail = ed->ed_prev;
>> } else {
>> -   ((ed_t *)m32_swap(
>> +   ((ed_t *)(uintptr_t)m32_swap(
>> *((__u32 *)>hwNextED)))->ed_prev = 
>> ed->ed_prev;
>> }
>> break;
>> @@ -819,7 +819,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
>> if (ohci->ed_bulktail == ed) {
>> ohci->ed_bulktail = ed->ed_prev;
>> } else {
>> -   ((ed_t *)m32_swap(
>> +   ((ed_t *)(uintptr_t)m32_swap(
>>  *((__u32 *)>hwNextED)))->ed_prev = 
>> ed->ed_prev;
>> }
>> break;
>> @@ -914,12 +914,13 @@ static void td_fill(ohci_t *ohci, unsigned int info,
>>
>> /* fill the old dummy TD */
>> td = urb_priv->td [index] =
>> -(td_t *)(m32_swap(urb_priv->ed->hwTailP) & 
>> ~0xf);
>> +(td_t *)(uintptr_t)
>> +(m32_swap(urb_priv->ed->hwTailP) & ~0xf);
>>
>> td->ed = urb_priv->ed;
>> td->next_dl_td = NULL;
>> td->index = index;
>> -   td->data = (__u32)data;
>> +   td->data = (uintptr_t)data;
>>  #ifdef OHCI_FILL_TRACE
>> if (usb_pipebulk(urb_priv->pipe) && usb_pipeout(urb_priv->pipe)) {
>> for (i = 0; i < len; i++)
>> @@ -1099,7 +1100,7 @@ static void check_status(td_t *td_list)
>>   * we reverse the reversed done-list */
>>  static td_t *dl_reverse_done_list(ohci_t *ohci)
>>  {
>> -   __u32 td_list_hc;
>> +   uintptr_t td_list_hc;
>> td_t 

Re: [U-Boot] [PATCH 1/2] drivers: USB: OHCI: allow compilation for 64-bit targets

2016-10-22 Thread Jagan Teki
On Fri, Oct 21, 2016 at 6:54 AM, Andre Przywara  wrote:
> OHCI has a known limitation of allowing only 32-bit DMA buffer
> addresses, so we have a lot of u32 variables around, which are assigned
> to pointers and vice versa. This obviously creates issues with 64-bit
> systems, so the compiler complains here and there.
> To allow compilation for 64-bit boards which use only memory below 4GB
> anyway (and to avoid more invasive fixes), adjust some casts and types
> and assume that the EDs and TDs are all located in the lower 4GB.
> This fixes compilation of the OHCI driver for the Pine64.
>
> Signed-off-by: Andre Przywara 
> ---
>  drivers/usb/host/ohci-hcd.c   | 21 +++--
>  drivers/usb/host/ohci-sunxi.c |  2 +-
>  drivers/usb/host/ohci.h   | 11 +++
>  3 files changed, 19 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
> index ccbfc02..0f6d03e 100644
> --- a/drivers/usb/host/ohci-hcd.c
> +++ b/drivers/usb/host/ohci-hcd.c
> @@ -682,7 +682,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
> ed->hwNextED = 0;
> flush_dcache_ed(ed);
> if (ohci->ed_controltail == NULL)
> -   ohci_writel(ed, >regs->ed_controlhead);
> +   ohci_writel((uintptr_t)ed, 
> >regs->ed_controlhead);
> else
> ohci->ed_controltail->hwNextED =
>m32_swap((unsigned 
> long)ed);
> @@ -700,7 +700,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
> ed->hwNextED = 0;
> flush_dcache_ed(ed);
> if (ohci->ed_bulktail == NULL)
> -   ohci_writel(ed, >regs->ed_bulkhead);
> +   ohci_writel((uintptr_t)ed, >regs->ed_bulkhead);
> else
> ohci->ed_bulktail->hwNextED =
>m32_swap((unsigned 
> long)ed);
> @@ -753,7 +753,7 @@ static void periodic_unlink(struct ohci *ohci, volatile 
> struct ed *ed,
>
> /* ED might have been unlinked through another path */
> while (*ed_p != 0) {
> -   if (((struct ed *)
> +   if (((struct ed *)(uintptr_t)
> m32_swap((unsigned long)ed_p)) == ed) 
> {
> *ed_p = ed->hwNextED;
> aligned_ed_p = (unsigned long)ed_p;
> @@ -762,7 +762,7 @@ static void periodic_unlink(struct ohci *ohci, volatile 
> struct ed *ed,
> aligned_ed_p + ARCH_DMA_MINALIGN);
> break;
> }
> -   ed_p = &(((struct ed *)
> +   ed_p = &(((struct ed *)(uintptr_t)
>  m32_swap((unsigned 
> long)ed_p))->hwNextED);
> }
> }
> @@ -798,7 +798,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
> if (ohci->ed_controltail == ed) {
> ohci->ed_controltail = ed->ed_prev;
> } else {
> -   ((ed_t *)m32_swap(
> +   ((ed_t *)(uintptr_t)m32_swap(
> *((__u32 *)>hwNextED)))->ed_prev = 
> ed->ed_prev;
> }
> break;
> @@ -819,7 +819,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
> if (ohci->ed_bulktail == ed) {
> ohci->ed_bulktail = ed->ed_prev;
> } else {
> -   ((ed_t *)m32_swap(
> +   ((ed_t *)(uintptr_t)m32_swap(
>  *((__u32 *)>hwNextED)))->ed_prev = 
> ed->ed_prev;
> }
> break;
> @@ -914,12 +914,13 @@ static void td_fill(ohci_t *ohci, unsigned int info,
>
> /* fill the old dummy TD */
> td = urb_priv->td [index] =
> -(td_t *)(m32_swap(urb_priv->ed->hwTailP) & ~0xf);
> +(td_t *)(uintptr_t)
> +(m32_swap(urb_priv->ed->hwTailP) & ~0xf);
>
> td->ed = urb_priv->ed;
> td->next_dl_td = NULL;
> td->index = index;
> -   td->data = (__u32)data;
> +   td->data = (uintptr_t)data;
>  #ifdef OHCI_FILL_TRACE
> if (usb_pipebulk(urb_priv->pipe) && usb_pipeout(urb_priv->pipe)) {
> for (i = 0; i < len; i++)
> @@ -1099,7 +1100,7 @@ static void check_status(td_t *td_list)
>   * we reverse the reversed done-list */
>  static td_t *dl_reverse_done_list(ohci_t *ohci)
>  {
> -   __u32 td_list_hc;
> +   uintptr_t td_list_hc;
> td_t *td_rev = NULL;
> td_t *td_list = NULL;
>
> @@ -1862,7 +1863,7 @@ static int hc_start(ohci_t *ohci)
> ohci_writel(0, >regs->ed_controlhead);
>

[U-Boot] [PATCH 1/2] drivers: USB: OHCI: allow compilation for 64-bit targets

2016-10-20 Thread Andre Przywara
OHCI has a known limitation of allowing only 32-bit DMA buffer
addresses, so we have a lot of u32 variables around, which are assigned
to pointers and vice versa. This obviously creates issues with 64-bit
systems, so the compiler complains here and there.
To allow compilation for 64-bit boards which use only memory below 4GB
anyway (and to avoid more invasive fixes), adjust some casts and types
and assume that the EDs and TDs are all located in the lower 4GB.
This fixes compilation of the OHCI driver for the Pine64.

Signed-off-by: Andre Przywara 
---
 drivers/usb/host/ohci-hcd.c   | 21 +++--
 drivers/usb/host/ohci-sunxi.c |  2 +-
 drivers/usb/host/ohci.h   | 11 +++
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index ccbfc02..0f6d03e 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -682,7 +682,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
ed->hwNextED = 0;
flush_dcache_ed(ed);
if (ohci->ed_controltail == NULL)
-   ohci_writel(ed, >regs->ed_controlhead);
+   ohci_writel((uintptr_t)ed, >regs->ed_controlhead);
else
ohci->ed_controltail->hwNextED =
   m32_swap((unsigned long)ed);
@@ -700,7 +700,7 @@ static int ep_link(ohci_t *ohci, ed_t *edi)
ed->hwNextED = 0;
flush_dcache_ed(ed);
if (ohci->ed_bulktail == NULL)
-   ohci_writel(ed, >regs->ed_bulkhead);
+   ohci_writel((uintptr_t)ed, >regs->ed_bulkhead);
else
ohci->ed_bulktail->hwNextED =
   m32_swap((unsigned long)ed);
@@ -753,7 +753,7 @@ static void periodic_unlink(struct ohci *ohci, volatile 
struct ed *ed,
 
/* ED might have been unlinked through another path */
while (*ed_p != 0) {
-   if (((struct ed *)
+   if (((struct ed *)(uintptr_t)
m32_swap((unsigned long)ed_p)) == ed) {
*ed_p = ed->hwNextED;
aligned_ed_p = (unsigned long)ed_p;
@@ -762,7 +762,7 @@ static void periodic_unlink(struct ohci *ohci, volatile 
struct ed *ed,
aligned_ed_p + ARCH_DMA_MINALIGN);
break;
}
-   ed_p = &(((struct ed *)
+   ed_p = &(((struct ed *)(uintptr_t)
 m32_swap((unsigned long)ed_p))->hwNextED);
}
}
@@ -798,7 +798,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
if (ohci->ed_controltail == ed) {
ohci->ed_controltail = ed->ed_prev;
} else {
-   ((ed_t *)m32_swap(
+   ((ed_t *)(uintptr_t)m32_swap(
*((__u32 *)>hwNextED)))->ed_prev = ed->ed_prev;
}
break;
@@ -819,7 +819,7 @@ static int ep_unlink(ohci_t *ohci, ed_t *edi)
if (ohci->ed_bulktail == ed) {
ohci->ed_bulktail = ed->ed_prev;
} else {
-   ((ed_t *)m32_swap(
+   ((ed_t *)(uintptr_t)m32_swap(
 *((__u32 *)>hwNextED)))->ed_prev = ed->ed_prev;
}
break;
@@ -914,12 +914,13 @@ static void td_fill(ohci_t *ohci, unsigned int info,
 
/* fill the old dummy TD */
td = urb_priv->td [index] =
-(td_t *)(m32_swap(urb_priv->ed->hwTailP) & ~0xf);
+(td_t *)(uintptr_t)
+(m32_swap(urb_priv->ed->hwTailP) & ~0xf);
 
td->ed = urb_priv->ed;
td->next_dl_td = NULL;
td->index = index;
-   td->data = (__u32)data;
+   td->data = (uintptr_t)data;
 #ifdef OHCI_FILL_TRACE
if (usb_pipebulk(urb_priv->pipe) && usb_pipeout(urb_priv->pipe)) {
for (i = 0; i < len; i++)
@@ -1099,7 +1100,7 @@ static void check_status(td_t *td_list)
  * we reverse the reversed done-list */
 static td_t *dl_reverse_done_list(ohci_t *ohci)
 {
-   __u32 td_list_hc;
+   uintptr_t td_list_hc;
td_t *td_rev = NULL;
td_t *td_list = NULL;
 
@@ -1862,7 +1863,7 @@ static int hc_start(ohci_t *ohci)
ohci_writel(0, >regs->ed_controlhead);
ohci_writel(0, >regs->ed_bulkhead);
 
-   ohci_writel((__u32)ohci->hcca,
+   ohci_writel((uintptr_t)ohci->hcca,
>regs->hcca); /* reset clears this */
 
fminterval = 0x2edf;
diff --git a/drivers/usb/host/ohci-sunxi.c b/drivers/usb/host/ohci-sunxi.c
index