RE: [PATCH V8 03/10] USB/ppc4xx: Add Synopsys DWC OTG Core Interface Layer

2011-02-11 Thread Tirumala Marri
>
> > dwc_read_reg32 is used nowhere throughout the code. One of dwc_read32
> > and
> > dwc_read_reg32 should be removed IMO. There was once only
> > dwc_read_reg32. In
> > version 5 of your patchset I believe. Why did you add another function?
> > AFAIK it is not correct to store pointers in u32 because they need 8
> > bytes
> > on 64-bit archs. So it was ok with the old dwc_read_reg32.
> > [Marri] If u32 is 8bytes isn't pointer type would be 8bytes as well.
>
> Sorry, I don't understand that. I think u32 is always 32bit = 4byte on
> all archs. Right?

Yes.

Use an unsigned long if you want to hold a pointer correctly on all
arches.

[Marri] I see your point.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH V8 03/10] USB/ppc4xx: Add Synopsys DWC OTG Core Interface Layer

2011-02-07 Thread Greg KH
On Tue, Feb 08, 2011 at 03:19:25AM +0300, Alexander Gordeev wrote:
> В Mon, 7 Feb 2011 10:53:25 -0800
> Tirumala Marri  пишет:
> 
> > dwc_read_reg32 is used nowhere throughout the code. One of dwc_read32 and
> > dwc_read_reg32 should be removed IMO. There was once only dwc_read_reg32. In
> > version 5 of your patchset I believe. Why did you add another function?
> > AFAIK it is not correct to store pointers in u32 because they need 8 bytes
> > on 64-bit archs. So it was ok with the old dwc_read_reg32.
> > [Marri] If u32 is 8bytes isn't pointer type would be 8bytes as well.
> 
> Sorry, I don't understand that. I think u32 is always 32bit = 4byte on
> all archs. Right?

Yes.

Use an unsigned long if you want to hold a pointer correctly on all
arches.

thanks,

greg k-h
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH V8 03/10] USB/ppc4xx: Add Synopsys DWC OTG Core Interface Layer

2011-02-07 Thread Alexander Gordeev
В Mon, 7 Feb 2011 10:53:25 -0800
Tirumala Marri  пишет:

> dwc_read_reg32 is used nowhere throughout the code. One of dwc_read32 and
> dwc_read_reg32 should be removed IMO. There was once only dwc_read_reg32. In
> version 5 of your patchset I believe. Why did you add another function?
> AFAIK it is not correct to store pointers in u32 because they need 8 bytes
> on 64-bit archs. So it was ok with the old dwc_read_reg32.
> [Marri] If u32 is 8bytes isn't pointer type would be 8bytes as well.

Sorry, I don't understand that. I think u32 is always 32bit = 4byte on
all archs. Right?

> I had change the API to avoid type castings to register addresses.

IMO it's now much worse because you pass a u32 value and cast it
internally to a pointer. I think it's unsafe and counter-intuitive. BTW
what is the problem with type casting to register addresses that you
mention? I've checked version 5 of your patchset (which is the last
version where the old API is used) and there are no casts.

-- 
  Alexander


signature.asc
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [PATCH V8 03/10] USB/ppc4xx: Add Synopsys DWC OTG Core Interface Layer

2011-02-07 Thread Tirumala Marri
dwc_read_reg32 is used nowhere throughout the code. One of dwc_read32 and
dwc_read_reg32 should be removed IMO. There was once only dwc_read_reg32. In
version 5 of your patchset I believe. Why did you add another function?
AFAIK it is not correct to store pointers in u32 because they need 8 bytes
on 64-bit archs. So it was ok with the old dwc_read_reg32.
[Marri] If u32 is 8bytes isn't pointer type would be 8bytes as well. I had
change the API to avoid type castings to register addresses.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH V8 03/10] USB/ppc4xx: Add Synopsys DWC OTG Core Interface Layer

2011-01-26 Thread Alexander Gordeev
В Wed, 19 Jan 2011 14:57:32 -0800
tma...@apm.com пишет:

> From: Tirumala Marri 
> 
> Core Interface Layer Common provides common functions for both host
> controller and peripheral controller.  CIL manages the memory map
> for the core. It also handles basic tasks like reading/writing the
> registers and data FIFOs in the controller. CIL performs basic
> services that are not specific to either the host or device modes
> of operation. These services include management of the OTG Host
> Negotiation Protocol (HNP) and Session Request Protocol (SRP).
> 
> Signed-off-by: Tirumala R Marri 
> Signed-off-by: Fushen Chen 
> Signed-off-by: Mark Miesfeld 
> ---
>  drivers/usb/dwc_otg/dwc_otg_cil.c  |  972 +
>  drivers/usb/dwc_otg/dwc_otg_cil.h  | 1220 
> 
>  drivers/usb/dwc_otg/dwc_otg_cil_intr.c |  616 
>  3 files changed, 2808 insertions(+), 0 deletions(-)
> 
[snip drivers/usb/dwc_otg/dwc_otg_cil.c]
> diff --git a/drivers/usb/dwc_otg/dwc_otg_cil.h 
> b/drivers/usb/dwc_otg/dwc_otg_cil.h
> new file mode 100644
> index 000..d97a8db
> --- /dev/null
> +++ b/drivers/usb/dwc_otg/dwc_otg_cil.h
> @@ -0,0 +1,1220 @@
> +/*
> + * DesignWare HS OTG controller driver
> + * Copyright (C) 2006 Synopsys, Inc.
> + * Portions Copyright (C) 2010 Applied Micro Circuits Corporation.
> + *
> + * 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.
> + *
> + * 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 for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, see http://www.gnu.org/licenses
> + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
> + * Suite 500, Boston, MA 02110-1335 USA.
> + *
> + * Based on Synopsys driver version 2.60a
> + * Modified by Mark Miesfeld 
> + * Modified by Stefan Roese , DENX Software Engineering
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
> IS"
> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL SYNOPSYS, INC. BE LIABLE FOR ANY DIRECT,
> + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES
> + * (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
> SERVICES;
> + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
> AND
> + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + */
> +
> +#if !defined(__DWC_CIL_H__)
> +#define __DWC_CIL_H__
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "dwc_otg_regs.h"
> +
> +#ifdef CONFIG_DWC_DEBUG
> +#define DEBUG
> +#endif
> +
> +/**
> + * Reads the content of a register.
> + */
> +static inline u32 dwc_read32(u32 reg)
> +{
> +#ifdef CONFIG_DWC_OTG_REG_LE
> + return in_le32((unsigned __iomem *)reg);
> +#else
> + return in_be32((unsigned __iomem *)reg);
> +#endif
> +};
> +static inline u32 dwc_read_reg32(u32 *reg)
> +{
> +#ifdef CONFIG_DWC_OTG_REG_LE
> + return in_le32(reg);
> +#else
> + return in_be32(reg);
> +#endif
> +};
> +

dwc_read_reg32 is used nowhere throughout the code. One of dwc_read32
and dwc_read_reg32 should be removed IMO. There was once only
dwc_read_reg32. In version 5 of your patchset I believe. Why did you
add another function? AFAIK it is not correct to store pointers in u32
because they need 8 bytes on 64-bit archs. So it was ok with the old
dwc_read_reg32.

> +/**
> + * Writes a register with a 32 bit value.
> + */
> +static inline void dwc_write32(u32 reg, const u32 value)
> +{
> +#ifdef CONFIG_DWC_OTG_REG_LE
> + out_le32((unsigned __iomem *)reg, value);
> +#else
> + out_be32((unsigned __iomem *)reg, value);
> +#endif
> +};
> +static inline void dwc_write_reg32(u32 *reg, const u32 value)
> +{
> +#ifdef CONFIG_DWC_OTG_REG_LE
> + out_le32(reg, value);
> +#else
> + out_be32(reg, value);
> +#endif
> +};
> +

Same thing here. dwc_write_reg32 is never used. And it should be used
instead of dwc_write32 probably.

> +/**
> + * This function modifies bit values in a register.  Using the
> + * algorithm: (reg_contents & ~clear_mask) | set_mask.
> + */
> +static inline
> + void dwc_modify_reg32(u32 *_reg, const u32 _clear_mask,
> +   const u32 _set_mask)
> +{
> +#ifdef CONFIG_DWC_OTG_REG_LE
> + out_le32(_reg, (in_le3