Re: [PATCH Ver 1.0 2/7] Subscribes for USB resources for TI DM644x EVM platform.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Swaminathan S <swami.iyer@xxxxxx> writes:

> This patch implements the support for USB VBUS, PHY control, DM644x USB memory
> maps, IRQ, USB Mode.  It initializes for a single instance of MUSB controller.
>
> Signed-off-by: Swaminathan S <swami.iyer@xxxxxx>

A couple minor comments below...

> ---
>  arch/arm/mach-davinci/board-dm644x-evm.c    |   46 +++++++++++++++++-
>  arch/arm/mach-davinci/dm644x.c              |   70 +++++++++++++++++++++++++++
>  arch/arm/mach-davinci/include/mach/dm644x.h |    3 +
>  arch/arm/mach-davinci/include/mach/usb.h    |   16 ++++++
>  4 files changed, 134 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
> index 1213a00..bafae44 100644
> --- a/arch/arm/mach-davinci/board-dm644x-evm.c
> +++ b/arch/arm/mach-davinci/board-dm644x-evm.c
> @@ -29,6 +29,7 @@
>  #include <linux/phy.h>
>  #include <linux/clk.h>
>  #include <linux/videodev2.h>
> +#include <linux/usb/musb.h>
>  
>  #include <media/tvp514x.h>
>  
> @@ -63,6 +64,8 @@
>  #define LXT971_PHY_ID	(0x001378e2)
>  #define LXT971_PHY_MASK	(0xfffffff0)
>  
> +static int dm644x_evm_set_vbus(struct device *dev, int is_on);
> +
>  static struct mtd_partition davinci_evm_norflash_partitions[] = {
>  	/* bootloader (UBL, U-Boot, etc) in first 5 sectors */
>  	{
> @@ -477,7 +480,6 @@ evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
>  	/* irlml6401 switches over 1A, in under 8 msec;
>  	 * now it can be managed by nDRV_VBUS ...
>  	 */
> -	setup_usb(500, 8);
>  
>  	return 0;
>  }
> @@ -699,6 +701,21 @@ static int davinci_phy_fixup(struct phy_device *phydev)
>  #define HAS_NAND 0
>  #endif
>  
> +static struct musb_hdrc_platform_data usb_evm_data[] = {
> +	{
> +#if defined(CONFIG_USB_MUSB_OTG)
> +		.mode = MUSB_OTG,
> +#elif defined(CONFIG_USB_MUSB_PERIPHERAL)
> +		.mode =  MUSB_PERIPHERAL,
> +#elif defined(CONFIG_USB_MUSB_HOST)
> +		.mode = MUSB_HOST,
> +#endif
> +		.power = 255,
> +		.potpgt = 8,
> +		.set_vbus = dm644x_evm_set_vbus,
> +	}
> +};
> +
>  static __init void davinci_evm_init(void)
>  {
>  	struct clk *aemif_clk;
> @@ -747,6 +764,7 @@ static __init void davinci_evm_init(void)
>  	phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
>  					davinci_phy_fixup);
>  
> +	dm644x_usb_configure(usb_evm_data, ARRAY_SIZE(usb_evm_data));
>  }
>  
>  static __init void davinci_evm_irq_init(void)
> @@ -754,6 +772,32 @@ static __init void davinci_evm_irq_init(void)
>  	davinci_irq_init();
>  }
>  
> +#define GPIO_nVBUS_DRV (DAVINCI_N_GPIO + 16) /* USB VBUS line */
> +static int vbus_state = -1;
> +static void evm_deferred_drvvbus(struct work_struct *ignored)
> +{
> +	gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state);
> +	vbus_state = !vbus_state;
> +}
> +
> +/*
> + * DM644x EVM USB VBUS handler.  On TI DM644x EVM USB VBUS is controller
> + * through I2C expander (0x3A) lines.  Tthis function schedules a
> + * work thread to handle the actual VBUS on/off operations.
> + */
> +static int dm644x_evm_set_vbus(struct device *dev, int is_on)
> +{
> +	static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus);

Move this declaration outside the function, it doesn't need to be
inside.

[...]

> diff --git a/arch/arm/mach-davinci/include/mach/dm644x.h b/arch/arm/mach-davinci/include/mach/dm644x.h
> index 0efb738..1f6f3fa 100644
> --- a/arch/arm/mach-davinci/include/mach/dm644x.h
> +++ b/arch/arm/mach-davinci/include/mach/dm644x.h
> @@ -27,6 +27,7 @@
>  #include <mach/emac.h>
>  #include <mach/asp.h>
>  #include <media/davinci/vpfe_capture.h>
> +#include <linux/usb/musb.h>
>  
>  #define DM644X_EMAC_BASE		(0x01C80000)
>  #define DM644X_EMAC_CNTRL_OFFSET	(0x0000)
> @@ -38,5 +39,7 @@
>  void __init dm644x_init(void);
>  void __init dm644x_init_asp(struct snd_platform_data *pdata);
>  void dm644x_set_vpfe_config(struct vpfe_config *cfg);
> +extern void dm644x_usb_configure(struct musb_hdrc_platform_data *pdata,
> +					u8 num_inst);
>  
>  #endif /* __ASM_ARCH_DM644X_H */
> diff --git a/arch/arm/mach-davinci/include/mach/usb.h b/arch/arm/mach-davinci/include/mach/usb.h
> index 435f228..96a60b1 100644
> --- a/arch/arm/mach-davinci/include/mach/usb.h
> +++ b/arch/arm/mach-davinci/include/mach/usb.h
> @@ -10,6 +10,8 @@
>  
>  #ifndef __ASM_ARCH_USB_H
>  #define __ASM_ARCH_USB_H
> +#include <mach/hardware.h>
> +#include <linux/io.h>
>  
>  /* DA8xx CFGCHIP2 (USB 2.0 PHY Control) register bits */
>  #define CFGCHIP2_PHYCLKGD	(1 << 17)
> @@ -34,6 +36,20 @@
>  #define CFGCHIP2_REFFREQ_24MHZ	(2 << 0)
>  #define CFGCHIP2_REFFREQ_48MHZ	(3 << 0)
>  
> +/* DMxxxx USB PHY definitions */
> +#define USBPHY_CTL_PADDR	(DAVINCI_SYSTEM_MODULE_BASE + 0x34)
> +#define USB_PHY_CTRL		IO_ADDRESS(USBPHY_CTL_PADDR)

IO_ADDRESS is soon to be deprecated. Please just define phys addr here
and use ioremap + read*/write* in the code.

> +#define USBPHY_PHYCLKGD		BIT(8)
> +#define USBPHY_SESNDEN		BIT(7)  /* v(sess_end) comparator */
> +#define USBPHY_VBDTCTEN		BIT(6)  /* v(bus) comparator */
> +#define USBPHY_VBUSSENS		BIT(5)  /* (dm355,ro) is vbus > 0.5V */
> +#define USBPHY_PHYPLLON		BIT(4)  /* override pll suspend */
> +#define USBPHY_CLKO1SEL		BIT(3)
> +#define USBPHY_OSCPDWN		BIT(2)
> +#define USBPHY_OTGPDWN		BIT(1)
> +#define USBPHY_PHYPDWN		BIT(0)
> +
>  struct	da8xx_ohci_root_hub;
>  
>  typedef void (*da8xx_ocic_handler_t)(struct da8xx_ohci_root_hub *hub,

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

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux