diff mbox

Add platform Support for DM646x USB.

Message ID 1250760146-5518-1-git-send-email-swami.iyer@ti.com (mailing list archive)
State Rejected
Headers show

Commit Message

Subbrathnam, Swaminathan Aug. 20, 2009, 9:22 a.m. UTC
Signed-off-by: Swaminathan S <swami.iyer@ti.com>

---
 arch/arm/mach-davinci/board-dm646x-evm.c |   34 ++++++++++++++++++++++++++++++
 arch/arm/mach-davinci/dm646x.c           |    8 +++++++
 2 files changed, 42 insertions(+), 0 deletions(-)

Comments

Kevin Hilman Aug. 25, 2009, 11:13 a.m. UTC | #1
Swaminathan S <swami.iyer@ti.com> writes:

>  Signed-off-by: Swaminathan S <swami.iyer@ti.com>

Please add a descriptive changelog.

Kevin

> ---
>  arch/arm/mach-davinci/board-dm646x-evm.c |   34 ++++++++++++++++++++++++++++++
>  arch/arm/mach-davinci/dm646x.c           |    8 +++++++
>  2 files changed, 42 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
> index 8c88fd0..c48b0a4 100644
> --- a/arch/arm/mach-davinci/board-dm646x-evm.c
> +++ b/arch/arm/mach-davinci/board-dm646x-evm.c
> @@ -59,6 +59,7 @@
>  /* CPLD Register 0 bits to control ATA */
>  #define DM646X_EVM_ATA_RST		BIT(0)
>  #define DM646X_EVM_ATA_PWD		BIT(1)
> +#define DM646X_EVM_USB_VBUS		BIT(7)
>  
>  #define DM646X_EVM_PHY_MASK		(0x2)
>  #define DM646X_EVM_MDIO_FREQUENCY	(2200000) /* PHY bus frequency */
> @@ -80,10 +81,13 @@ static struct davinci_uart_config uart_config __initdata = {
>  	.enabled_uarts = (1 << 0),
>  };
>  
> +struct i2c_client *cple_reg0_client;
> +
>  /* CPLD Register 0 Client: used for I/O Control */
>  static int cpld_reg0_probe(struct i2c_client *client,
>  			   const struct i2c_device_id *id)
>  {
> +	cple_reg0_client = client;
>  	if (HAS_ATA) {
>  		u8 data;
>  		struct i2c_msg msg[2] = {
> @@ -107,9 +111,39 @@ static int cpld_reg0_probe(struct i2c_client *client,
>  		i2c_transfer(client->adapter, msg + 1, 1);
>  	}
>  
> +	setup_usb(500, 8);
> +
>  	return 0;
>  }
>  
> +void usb_vbus_control(u8 on)
> +{
> +	u8 data;
> +	struct i2c_msg msg[2] = {
> +		{
> +			.addr = cple_reg0_client->addr,
> +			.flags = I2C_M_RD,
> +			.len = 1,
> +			.buf = &data,
> +		},
> +		{
> +			.addr = cple_reg0_client->addr,
> +			.flags = 0,
> +			.len = 1,
> +			.buf = &data,
> +		},
> +	};
> +
> +	i2c_transfer(cple_reg0_client->adapter, msg, 1);
> +	if (on)
> +		data |= DM646X_EVM_USB_VBUS;
> +	else
> +		data &= ~DM646X_EVM_USB_VBUS;
> +
> +	i2c_transfer(cple_reg0_client->adapter, msg + 1, 1);
> +}
> +EXPORT_SYMBOL(usb_vbus_control);
> +
>  static const struct i2c_device_id cpld_reg_ids[] = {
>  	{ "cpld_reg0", 0, },
>  	{ },
> diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
> index a9b20e5..633a25b 100644
> --- a/arch/arm/mach-davinci/dm646x.c
> +++ b/arch/arm/mach-davinci/dm646x.c
> @@ -315,6 +315,13 @@ static struct clk vpif1_clk = {
>  	.flags = ALWAYS_ENABLED,
>  };
>  
> +static struct clk usb_clk = {
> +	.name = "usb",
> +	.parent = &pll1_sysclk3,
> +	.lpsc = DAVINCI_LPSC_USB,
> +	.flags = ALWAYS_ENABLED,
> +};
> +
>  struct davinci_clk dm646x_clks[] = {
>  	CLK(NULL, "ref", &ref_clk),
>  	CLK(NULL, "aux", &aux_clkin),
> @@ -355,6 +362,7 @@ struct davinci_clk dm646x_clks[] = {
>  	CLK("palm_bk3710", NULL, &ide_clk),
>  	CLK(NULL, "vpif0", &vpif0_clk),
>  	CLK(NULL, "vpif1", &vpif1_clk),
> +	CLK(NULL, "usb", &usb_clk),
>  	CLK(NULL, NULL, NULL),
>  };
>  
> -- 
> 1.6.0.rc1.64.g61192
>
> _______________________________________________
> Davinci-linux-open-source mailing list
> Davinci-linux-open-source@linux.davincidsp.com
> http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
Kevin Hilman Aug. 25, 2009, 11:54 a.m. UTC | #2
Swaminathan S <swami.iyer@ti.com> writes:

Please add descriptive changelog.

>  Signed-off-by: Swaminathan S <swami.iyer@ti.com>
>
> ---
>  arch/arm/mach-davinci/board-dm646x-evm.c |   34 ++++++++++++++++++++++++++++++
>  arch/arm/mach-davinci/dm646x.c           |    8 +++++++
>  2 files changed, 42 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
> index 8c88fd0..c48b0a4 100644
> --- a/arch/arm/mach-davinci/board-dm646x-evm.c
> +++ b/arch/arm/mach-davinci/board-dm646x-evm.c
> @@ -59,6 +59,7 @@
>  /* CPLD Register 0 bits to control ATA */
>  #define DM646X_EVM_ATA_RST		BIT(0)
>  #define DM646X_EVM_ATA_PWD		BIT(1)
> +#define DM646X_EVM_USB_VBUS		BIT(7)
>  
>  #define DM646X_EVM_PHY_MASK		(0x2)
>  #define DM646X_EVM_MDIO_FREQUENCY	(2200000) /* PHY bus frequency */
> @@ -80,10 +81,13 @@ static struct davinci_uart_config uart_config __initdata = {
>  	.enabled_uarts = (1 << 0),
>  };
>  
> +struct i2c_client *cple_reg0_client;
> +

should be static.

>  /* CPLD Register 0 Client: used for I/O Control */
>  static int cpld_reg0_probe(struct i2c_client *client,
>  			   const struct i2c_device_id *id)
>  {
> +	cple_reg0_client = client;
>  	if (HAS_ATA) {
>  		u8 data;
>  		struct i2c_msg msg[2] = {
> @@ -107,9 +111,39 @@ static int cpld_reg0_probe(struct i2c_client *client,
>  		i2c_transfer(client->adapter, msg + 1, 1);
>  	}
>  
> +	setup_usb(500, 8);
> +
>  	return 0;
>  }
>  
> +void usb_vbus_control(u8 on)
> +{
> +	u8 data;
> +	struct i2c_msg msg[2] = {
> +		{
> +			.addr = cple_reg0_client->addr,
> +			.flags = I2C_M_RD,
> +			.len = 1,
> +			.buf = &data,
> +		},
> +		{
> +			.addr = cple_reg0_client->addr,
> +			.flags = 0,
> +			.len = 1,
> +			.buf = &data,
> +		},
> +	};
> +
> +	i2c_transfer(cple_reg0_client->adapter, msg, 1);
> +	if (on)
> +		data |= DM646X_EVM_USB_VBUS;
> +	else
> +		data &= ~DM646X_EVM_USB_VBUS;
> +
> +	i2c_transfer(cple_reg0_client->adapter, msg + 1, 1);
> +}
> +EXPORT_SYMBOL(usb_vbus_control);
> +
>  static const struct i2c_device_id cpld_reg_ids[] = {
>  	{ "cpld_reg0", 0, },
>  	{ },
> diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
> index a9b20e5..633a25b 100644
> --- a/arch/arm/mach-davinci/dm646x.c
> +++ b/arch/arm/mach-davinci/dm646x.c
> @@ -315,6 +315,13 @@ static struct clk vpif1_clk = {
>  	.flags = ALWAYS_ENABLED,
>  };
>  
> +static struct clk usb_clk = {
> +	.name = "usb",
> +	.parent = &pll1_sysclk3,
> +	.lpsc = DAVINCI_LPSC_USB,
> +	.flags = ALWAYS_ENABLED,

No.  Please don't use ALWAYS_ENABLE.  Driver/platform code should use clk API to enable/disable.

Kevin

> +};
> +
>  struct davinci_clk dm646x_clks[] = {
>  	CLK(NULL, "ref", &ref_clk),
>  	CLK(NULL, "aux", &aux_clkin),
> @@ -355,6 +362,7 @@ struct davinci_clk dm646x_clks[] = {
>  	CLK("palm_bk3710", NULL, &ide_clk),
>  	CLK(NULL, "vpif0", &vpif0_clk),
>  	CLK(NULL, "vpif1", &vpif1_clk),
> +	CLK(NULL, "usb", &usb_clk),
>  	CLK(NULL, NULL, NULL),
>  };
>  
> -- 
> 1.6.0.rc1.64.g61192
>
> _______________________________________________
> Davinci-linux-open-source mailing list
> Davinci-linux-open-source@linux.davincidsp.com
> http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
diff mbox

Patch

diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index 8c88fd0..c48b0a4 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -59,6 +59,7 @@ 
 /* CPLD Register 0 bits to control ATA */
 #define DM646X_EVM_ATA_RST		BIT(0)
 #define DM646X_EVM_ATA_PWD		BIT(1)
+#define DM646X_EVM_USB_VBUS		BIT(7)
 
 #define DM646X_EVM_PHY_MASK		(0x2)
 #define DM646X_EVM_MDIO_FREQUENCY	(2200000) /* PHY bus frequency */
@@ -80,10 +81,13 @@  static struct davinci_uart_config uart_config __initdata = {
 	.enabled_uarts = (1 << 0),
 };
 
+struct i2c_client *cple_reg0_client;
+
 /* CPLD Register 0 Client: used for I/O Control */
 static int cpld_reg0_probe(struct i2c_client *client,
 			   const struct i2c_device_id *id)
 {
+	cple_reg0_client = client;
 	if (HAS_ATA) {
 		u8 data;
 		struct i2c_msg msg[2] = {
@@ -107,9 +111,39 @@  static int cpld_reg0_probe(struct i2c_client *client,
 		i2c_transfer(client->adapter, msg + 1, 1);
 	}
 
+	setup_usb(500, 8);
+
 	return 0;
 }
 
+void usb_vbus_control(u8 on)
+{
+	u8 data;
+	struct i2c_msg msg[2] = {
+		{
+			.addr = cple_reg0_client->addr,
+			.flags = I2C_M_RD,
+			.len = 1,
+			.buf = &data,
+		},
+		{
+			.addr = cple_reg0_client->addr,
+			.flags = 0,
+			.len = 1,
+			.buf = &data,
+		},
+	};
+
+	i2c_transfer(cple_reg0_client->adapter, msg, 1);
+	if (on)
+		data |= DM646X_EVM_USB_VBUS;
+	else
+		data &= ~DM646X_EVM_USB_VBUS;
+
+	i2c_transfer(cple_reg0_client->adapter, msg + 1, 1);
+}
+EXPORT_SYMBOL(usb_vbus_control);
+
 static const struct i2c_device_id cpld_reg_ids[] = {
 	{ "cpld_reg0", 0, },
 	{ },
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index a9b20e5..633a25b 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -315,6 +315,13 @@  static struct clk vpif1_clk = {
 	.flags = ALWAYS_ENABLED,
 };
 
+static struct clk usb_clk = {
+	.name = "usb",
+	.parent = &pll1_sysclk3,
+	.lpsc = DAVINCI_LPSC_USB,
+	.flags = ALWAYS_ENABLED,
+};
+
 struct davinci_clk dm646x_clks[] = {
 	CLK(NULL, "ref", &ref_clk),
 	CLK(NULL, "aux", &aux_clkin),
@@ -355,6 +362,7 @@  struct davinci_clk dm646x_clks[] = {
 	CLK("palm_bk3710", NULL, &ide_clk),
 	CLK(NULL, "vpif0", &vpif0_clk),
 	CLK(NULL, "vpif1", &vpif1_clk),
+	CLK(NULL, "usb", &usb_clk),
 	CLK(NULL, NULL, NULL),
 };