public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
@ 2012-02-28  9:08 Meng Zhang
  2012-02-28 11:38 ` Sergei Shtylyov
  2012-02-28 15:30 ` Alan Stern
  0 siblings, 2 replies; 11+ messages in thread
From: Meng Zhang @ 2012-02-28  9:08 UTC (permalink / raw)
  To: mdharm-usb, phil, stern; +Cc: linux-usb, usb-storage, linux-kernel

from: Meng Zhang <meng.zhang@mediatek.com>

1. Add entrys for mediatek MT6276M in unusual_devs.h

2. Add init function for mediatek MT6276M to switch to COM port mode

3. usb-devices outputs after running with this patch:
T:  Bus=02 Lev=01 Prnt=01 Port=05 Cnt=01 Dev#= 48 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0e8d ProdID=00a1 Rev=02.00
S:  Manufacturer=MediaTek Inc
S:  Product=Product
C:  #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option

4. patch based on branch:
	git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


Signed-off-by: Meng Zhang <meng.zhang@mediatek.com>
---

  drivers/usb/storage/initializers.c |   27 +++++++++++++++++++++++++++
  drivers/usb/storage/initializers.h |    3 +++
  drivers/usb/storage/unusual_devs.h |    9 +++++++++
  3 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/storage/initializers.c 
b/drivers/usb/storage/initializers.c
index 105d900..44985a1 100644
--- a/drivers/usb/storage/initializers.c
+++ b/drivers/usb/storage/initializers.c
@@ -104,3 +104,30 @@ int usb_stor_huawei_e220_init(struct us_data *us)
  	US_DEBUGP("Huawei mode set result is %d\n", result);
  	return 0;
  }
+
+/* switch MediaTek MT6276M to COM port mode */
+int usb_stor_mediatek_mt6276m_init(struct us_data *us)
+{
+	const unsigned char rezero_msg[] = {
+	  0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12,
+	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf0,
+	  0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+	};
+	char *buffer;
+	int result;
+
+	US_DEBUGP("Initializing mediatek USB device...\n");
+
+	buffer = kzalloc(32, GFP_KERNEL);
+	if (buffer == NULL)
+		return USB_STOR_TRANSPORT_ERROR;
+
+	memcpy(buffer, rezero_msg, sizeof(rezero_msg));
+	result = usb_stor_bulk_transfer_buf(us,
+			us->send_bulk_pipe,
+			buffer, sizeof(rezero_msg), NULL);
+	
+	kfree(buffer);
+	return result;
+}
diff --git a/drivers/usb/storage/initializers.h 
b/drivers/usb/storage/initializers.h
index 529327f..6c9337f 100644
--- a/drivers/usb/storage/initializers.h
+++ b/drivers/usb/storage/initializers.h
@@ -48,3 +48,6 @@ int usb_stor_ucr61s2b_init(struct us_data *us);

  /* This places the HUAWEI E220 devices in multi-port mode */
  int usb_stor_huawei_e220_init(struct us_data *us);
+
+/* switch MediaTek MT6276M to COM port mode */
+int usb_stor_mediatek_mt6276m_init(struct us_data *us);
diff --git a/drivers/usb/storage/unusual_devs.h 
b/drivers/usb/storage/unusual_devs.h
index 856ad92..574c291 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1356,6 +1356,15 @@ UNUSUAL_DEV( 0x0e21, 0x0520, 0x0100, 0x0100,
  		USB_SC_DEVICE, USB_PR_BULK, NULL,
  		US_FL_NEED_OVERRIDE ),

+/* Reported by Meng Zhang <meng.zhang@mediatek.com>
+ * switch mediatek USB devices into COM port mode
+ */
+UNUSUAL_DEV(0x0e8d, 0x0002, 0x0000, 0x0300,
+		"MediaTek Inc.",
+		"MT6276M",
+		USB_SC_DEVICE, USB_PR_DEVICE,
+		usb_stor_mediatek_mt6276m_init, 0),
+
  /* Submitted by Antoine Mairesse <antoine.mairesse@free.fr> */
  UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300,
  		"USB",

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
  2012-02-28  9:08 Meng Zhang
@ 2012-02-28 11:38 ` Sergei Shtylyov
  2012-02-28 11:59   ` Meng Zhang (张萌)
  2012-02-28 15:30 ` Alan Stern
  1 sibling, 1 reply; 11+ messages in thread
From: Sergei Shtylyov @ 2012-02-28 11:38 UTC (permalink / raw)
  To: Meng Zhang; +Cc: mdharm-usb, phil, stern, linux-usb, usb-storage, linux-kernel

Hello.

On 28-02-2012 13:08, Meng Zhang wrote:

> from: Meng Zhang <meng.zhang@mediatek.com>

> 1. Add entrys for mediatek MT6276M in unusual_devs.h

> 2. Add init function for mediatek MT6276M to switch to COM port mode

> 3. usb-devices outputs after running with this patch:
> T: Bus=02 Lev=01 Prnt=01 Port=05 Cnt=01 Dev#= 48 Spd=480 MxCh= 0
> D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
> P: Vendor=0e8d ProdID=00a1 Rev=02.00
> S: Manufacturer=MediaTek Inc
> S: Product=Product
> C: #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA
> I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
> I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
> I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option

> 4. patch based on branch:
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

    This information (4) should be under the --- tear line.

> Signed-off-by: Meng Zhang <meng.zhang@mediatek.com>
[...]

> diff --git a/drivers/usb/storage/initializers.c
> b/drivers/usb/storage/initializers.c
> index 105d900..44985a1 100644
> --- a/drivers/usb/storage/initializers.c
> +++ b/drivers/usb/storage/initializers.c
> @@ -104,3 +104,30 @@ int usb_stor_huawei_e220_init(struct us_data *us)
> US_DEBUGP("Huawei mode set result is %d\n", result);
> return 0;
> }
> +
> +/* switch MediaTek MT6276M to COM port mode */
> +int usb_stor_mediatek_mt6276m_init(struct us_data *us)
> +{
> + const unsigned char rezero_msg[] = {

    Unfortunately, when I reply to messages with "format=flowed", source 
formatting is spoiled. :-(

> + 0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12,

    All indentation here should be done with tabs, not tab and two spaces.

> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf0,
> + 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
> + };

WBR, Sergei

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
  2012-02-28 11:38 ` Sergei Shtylyov
@ 2012-02-28 11:59   ` Meng Zhang (张萌)
  2012-02-29  0:45     ` Meng Zhang (张萌)
  0 siblings, 1 reply; 11+ messages in thread
From: Meng Zhang (张萌) @ 2012-02-28 11:59 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: mdharm-usb@one-eyed-alien.net, phil@ipom.com,
	stern@rowland.harvard.edu, linux-usb@vger.kernel.org,
	usb-storage@lists.one-eyed-alien.net,
	linux-kernel@vger.kernel.org

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 2811 bytes --]

Hi, about the indentation I saw in initializers.c is also tab with 2 spaces.. should I change this to 2 tabs manually?

Thanks!

BR.
Meng Zhang

-----Original Message-----
From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-owner@vger.kernel.org] On Behalf Of Sergei Shtylyov
Sent: Tuesday, February 28, 2012 7:39 PM
To: Meng Zhang (ÕÅÃÈ)
Cc: mdharm-usb@one-eyed-alien.net; phil@ipom.com; stern@rowland.harvard.edu; linux-usb@vger.kernel.org; usb-storage@lists.one-eyed-alien.net; linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry

Hello.

On 28-02-2012 13:08, Meng Zhang wrote:

> from: Meng Zhang <meng.zhang@mediatek.com>

> 1. Add entrys for mediatek MT6276M in unusual_devs.h

> 2. Add init function for mediatek MT6276M to switch to COM port mode

> 3. usb-devices outputs after running with this patch:
> T: Bus=02 Lev=01 Prnt=01 Port=05 Cnt=01 Dev#= 48 Spd=480 MxCh= 0
> D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
> P: Vendor=0e8d ProdID=00a1 Rev=02.00
> S: Manufacturer=MediaTek Inc
> S: Product=Product
> C: #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA
> I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
> I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
> I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option

> 4. patch based on branch:
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

    This information (4) should be under the --- tear line.

> Signed-off-by: Meng Zhang <meng.zhang@mediatek.com>
[...]

> diff --git a/drivers/usb/storage/initializers.c
> b/drivers/usb/storage/initializers.c
> index 105d900..44985a1 100644
> --- a/drivers/usb/storage/initializers.c
> +++ b/drivers/usb/storage/initializers.c
> @@ -104,3 +104,30 @@ int usb_stor_huawei_e220_init(struct us_data *us) 
> US_DEBUGP("Huawei mode set result is %d\n", result); return 0; }
> +
> +/* switch MediaTek MT6276M to COM port mode */ int 
> +usb_stor_mediatek_mt6276m_init(struct us_data *us) {  const unsigned 
> +char rezero_msg[] = {

    Unfortunately, when I reply to messages with "format=flowed", source formatting is spoiled. :-(

> + 0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12,

    All indentation here should be done with tabs, not tab and two spaces.

> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf0, 0x01, 0x03, 0x00, 
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
> + 0x00 };

WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at  http://vger.kernel.org/majordomo-info.html
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
  2012-02-28  9:08 Meng Zhang
  2012-02-28 11:38 ` Sergei Shtylyov
@ 2012-02-28 15:30 ` Alan Stern
  2012-02-29  0:25   ` Meng Zhang (张萌)
  1 sibling, 1 reply; 11+ messages in thread
From: Alan Stern @ 2012-02-28 15:30 UTC (permalink / raw)
  To: Meng Zhang
  Cc: Josua Dietze, Matthew Dharm, Phil Dibowitz, USB list,
	USB Storage list, Kernel development list

On Tue, 28 Feb 2012, Meng Zhang wrote:

> from: Meng Zhang <meng.zhang@mediatek.com>
> 
> 1. Add entrys for mediatek MT6276M in unusual_devs.h
> 
> 2. Add init function for mediatek MT6276M to switch to COM port mode
> 
> 3. usb-devices outputs after running with this patch:
> T:  Bus=02 Lev=01 Prnt=01 Port=05 Cnt=01 Dev#= 48 Spd=480 MxCh= 0
> D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
> P:  Vendor=0e8d ProdID=00a1 Rev=02.00
> S:  Manufacturer=MediaTek Inc
> S:  Product=Product
> C:  #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA
> I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
> I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
> I:  If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
> 
> 4. patch based on branch:
> 	git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> 
> 
> Signed-off-by: Meng Zhang <meng.zhang@mediatek.com>

Nowadays, aren't such things handled in userspace by the usb_modeswitch 
program rather than in the kernel driver?

Alan Stern


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
  2012-02-28 15:30 ` Alan Stern
@ 2012-02-29  0:25   ` Meng Zhang (张萌)
  2012-02-29  4:07     ` Matthew Dharm
  0 siblings, 1 reply; 11+ messages in thread
From: Meng Zhang (张萌) @ 2012-02-29  0:25 UTC (permalink / raw)
  To: Alan Stern
  Cc: Josua Dietze, Matthew Dharm, Phil Dibowitz, USB list,
	USB Storage list, Kernel development list

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 2031 bytes --]

Hi Alan,

As far as I know, many other devices used this init function in unusual_devs.h for their "ZeroCD" feature, and I think this is more convenient than let device user install utilities like usb_modeswitch and input command manually. 

Thanks.

BR.
Meng Zhang

-----Original Message-----
From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-owner@vger.kernel.org] On Behalf Of Alan Stern
Sent: Tuesday, February 28, 2012 11:31 PM
To: Meng Zhang (ÕÅÃÈ)
Cc: Josua Dietze; Matthew Dharm; Phil Dibowitz; USB list; USB Storage list; Kernel development list
Subject: Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry

On Tue, 28 Feb 2012, Meng Zhang wrote:

> from: Meng Zhang <meng.zhang@mediatek.com>
> 
> 1. Add entrys for mediatek MT6276M in unusual_devs.h
> 
> 2. Add init function for mediatek MT6276M to switch to COM port mode
> 
> 3. usb-devices outputs after running with this patch:
> T:  Bus=02 Lev=01 Prnt=01 Port=05 Cnt=01 Dev#= 48 Spd=480 MxCh= 0
> D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
> P:  Vendor=0e8d ProdID=00a1 Rev=02.00
> S:  Manufacturer=MediaTek Inc
> S:  Product=Product
> C:  #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA
> I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
> I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
> I:  If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
> 
> 4. patch based on branch:
> 	git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> 
> 
> Signed-off-by: Meng Zhang <meng.zhang@mediatek.com>

Nowadays, aren't such things handled in userspace by the usb_modeswitch program rather than in the kernel driver?

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at  http://vger.kernel.org/majordomo-info.html
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
  2012-02-28 11:59   ` Meng Zhang (张萌)
@ 2012-02-29  0:45     ` Meng Zhang (张萌)
  0 siblings, 0 replies; 11+ messages in thread
From: Meng Zhang (张萌) @ 2012-02-29  0:45 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: mdharm-usb@one-eyed-alien.net, phil@ipom.com,
	stern@rowland.harvard.edu, linux-usb@vger.kernel.org,
	usb-storage@lists.one-eyed-alien.net,
	linux-kernel@vger.kernel.org

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3514 bytes --]

Dear Sergei,

Sorry I misunderstand it. I'll correct the format and re-submit soon.

Thanks.

BR.
Meng Zhang

-----Original Message-----
From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-owner@vger.kernel.org] On Behalf Of Meng Zhang (张萌)
Sent: Tuesday, February 28, 2012 8:00 PM
To: Sergei Shtylyov
Cc: mdharm-usb@one-eyed-alien.net; phil@ipom.com; stern@rowland.harvard.edu; linux-usb@vger.kernel.org; usb-storage@lists.one-eyed-alien.net; linux-kernel@vger.kernel.org
Subject: RE: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry

Hi, about the indentation I saw in initializers.c is also tab with 2 spaces.. should I change this to 2 tabs manually?

Thanks!

BR.
Meng Zhang

-----Original Message-----
From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-owner@vger.kernel.org] On Behalf Of Sergei Shtylyov
Sent: Tuesday, February 28, 2012 7:39 PM
To: Meng Zhang (张萌)
Cc: mdharm-usb@one-eyed-alien.net; phil@ipom.com; stern@rowland.harvard.edu; linux-usb@vger.kernel.org; usb-storage@lists.one-eyed-alien.net; linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry

Hello.

On 28-02-2012 13:08, Meng Zhang wrote:

> from: Meng Zhang <meng.zhang@mediatek.com>

> 1. Add entrys for mediatek MT6276M in unusual_devs.h

> 2. Add init function for mediatek MT6276M to switch to COM port mode

> 3. usb-devices outputs after running with this patch:
> T: Bus=02 Lev=01 Prnt=01 Port=05 Cnt=01 Dev#= 48 Spd=480 MxCh= 0
> D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
> P: Vendor=0e8d ProdID=00a1 Rev=02.00
> S: Manufacturer=MediaTek Inc
> S: Product=Product
> C: #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA
> I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
> I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
> I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option

> 4. patch based on branch:
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

    This information (4) should be under the --- tear line.

> Signed-off-by: Meng Zhang <meng.zhang@mediatek.com>
[...]

> diff --git a/drivers/usb/storage/initializers.c
> b/drivers/usb/storage/initializers.c
> index 105d900..44985a1 100644
> --- a/drivers/usb/storage/initializers.c
> +++ b/drivers/usb/storage/initializers.c
> @@ -104,3 +104,30 @@ int usb_stor_huawei_e220_init(struct us_data *us) 
> US_DEBUGP("Huawei mode set result is %d\n", result); return 0; }
> +
> +/* switch MediaTek MT6276M to COM port mode */ int 
> +usb_stor_mediatek_mt6276m_init(struct us_data *us) {  const unsigned 
> +char rezero_msg[] = {

    Unfortunately, when I reply to messages with "format=flowed", source formatting is spoiled. :-(

> + 0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12,

    All indentation here should be done with tabs, not tab and two spaces.

> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf0, 0x01, 0x03, 0x00, 
> + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
> + 0x00 };

WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at  http://vger.kernel.org/majordomo-info.html
\x04韬{.n?壏煯壄?%娝lzwm呴b濍Р骒r笡zXЩ^[琻)韰骅w*jg?秹殠娸/侁鋤罐枈?娹櫒璀??摺玜囤\x7f\x1e瓽珴閔?鎗:+v墾妛鑶佶
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
@ 2012-02-29  2:37 Meng Zhang
  0 siblings, 0 replies; 11+ messages in thread
From: Meng Zhang @ 2012-02-29  2:37 UTC (permalink / raw)
  To: mdharm-usb, phil, stern; +Cc: linux-usb, usb-storage, linux-kernel

from: Meng Zhang <meng.zhang@mediatek.com>

1. Add entrys for mediatek MT6276M in unusual_devs.h

2. Add init function for mediatek MT6276M to switch to COM port mode

3. usb-devices outputs after running with this patch:
T:  Bus=02 Lev=01 Prnt=01 Port=05 Cnt=01 Dev#= 48 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0e8d ProdID=00a1 Rev=02.00
S:  Manufacturer=MediaTek Inc
S:  Product=Product
C:  #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option

Signed-off-by: Meng Zhang <meng.zhang@mediatek.com>
---

this patch is based on branch:
	git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


  drivers/usb/storage/initializers.c |   27 +++++++++++++++++++++++++++
  drivers/usb/storage/initializers.h |    3 +++
  drivers/usb/storage/unusual_devs.h |    9 +++++++++
  3 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/storage/initializers.c 
b/drivers/usb/storage/initializers.c
index 105d900..3ea233e 100644
--- a/drivers/usb/storage/initializers.c
+++ b/drivers/usb/storage/initializers.c
@@ -104,3 +104,30 @@ int usb_stor_huawei_e220_init(struct us_data *us)
  	US_DEBUGP("Huawei mode set result is %d\n", result);
  	return 0;
  }
+
+/* switch MediaTek MT6276M to COM port mode */
+int usb_stor_mediatek_mt6276m_init(struct us_data *us)
+{
+	const unsigned char rezero_msg[] = {
+		0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf0,
+		0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+	};
+	char *buffer;
+	int result;
+
+	US_DEBUGP("Initializing mediatek USB device...\n");
+
+	buffer = kzalloc(32, GFP_KERNEL);
+	if (buffer == NULL)
+		return USB_STOR_TRANSPORT_ERROR;
+
+	memcpy(buffer, rezero_msg, sizeof(rezero_msg));
+	result = usb_stor_bulk_transfer_buf(us,
+			us->send_bulk_pipe,
+			buffer, sizeof(rezero_msg), NULL);
+	
+	kfree(buffer);
+	return result;
+}
diff --git a/drivers/usb/storage/initializers.h 
b/drivers/usb/storage/initializers.h
index 529327f..6c9337f 100644
--- a/drivers/usb/storage/initializers.h
+++ b/drivers/usb/storage/initializers.h
@@ -48,3 +48,6 @@ int usb_stor_ucr61s2b_init(struct us_data *us);

  /* This places the HUAWEI E220 devices in multi-port mode */
  int usb_stor_huawei_e220_init(struct us_data *us);
+
+/* switch MediaTek MT6276M to COM port mode */
+int usb_stor_mediatek_mt6276m_init(struct us_data *us);
diff --git a/drivers/usb/storage/unusual_devs.h 
b/drivers/usb/storage/unusual_devs.h
index 856ad92..574c291 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1356,6 +1356,15 @@ UNUSUAL_DEV( 0x0e21, 0x0520, 0x0100, 0x0100,
  		USB_SC_DEVICE, USB_PR_BULK, NULL,
  		US_FL_NEED_OVERRIDE ),

+/* Reported by Meng Zhang <meng.zhang@mediatek.com>
+ * switch mediatek USB devices into COM port mode
+ */
+UNUSUAL_DEV(0x0e8d, 0x0002, 0x0000, 0x0300,
+		"MediaTek Inc.",
+		"MT6276M",
+		USB_SC_DEVICE, USB_PR_DEVICE,
+		usb_stor_mediatek_mt6276m_init, 0),
+
  /* Submitted by Antoine Mairesse <antoine.mairesse@free.fr> */
  UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300,
  		"USB",

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
  2012-02-29  0:25   ` Meng Zhang (张萌)
@ 2012-02-29  4:07     ` Matthew Dharm
  2012-02-29  6:03       ` Meng Zhang (张萌)
  0 siblings, 1 reply; 11+ messages in thread
From: Matthew Dharm @ 2012-02-29  4:07 UTC (permalink / raw)
  To: Meng Zhang (张萌)
  Cc: Alan Stern, Josua Dietze, Phil Dibowitz, USB list,
	USB Storage list, Kernel development list

Devices should not be added to unusual_devs.h unless the device CANNOT
use the usb_modeswitch method.  This most commonly applies when the
device's usb-storage emulation is poor, and the probing commands sent
by usb-storage cause the device to crash.

It is much more convenient for users to just upgrade their
usb_modeswitch utility than it is for them to upgrade a kernel, which
is much more difficult and much more rare.  As for 'input command
manually', that is what udev scripts are for.

If this can be handled from userspace by usb_modeswitch, then that is
where it should be done.

Matt

2012/2/28 Meng Zhang (张萌) <Meng.Zhang@mediatek.com>:
> Hi Alan,
>
> As far as I know, many other devices used this init function in unusual_devs.h for their "ZeroCD" feature, and I think this is more convenient than let device user install utilities like usb_modeswitch and input command manually.
>
> Thanks.
>
> BR.
> Meng Zhang
>
> -----Original Message-----
> From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-owner@vger.kernel.org] On Behalf Of Alan Stern
> Sent: Tuesday, February 28, 2012 11:31 PM
> To: Meng Zhang (张萌)
> Cc: Josua Dietze; Matthew Dharm; Phil Dibowitz; USB list; USB Storage list; Kernel development list
> Subject: Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
>
> On Tue, 28 Feb 2012, Meng Zhang wrote:
>
>> from: Meng Zhang <meng.zhang@mediatek.com>
>>
>> 1. Add entrys for mediatek MT6276M in unusual_devs.h
>>
>> 2. Add init function for mediatek MT6276M to switch to COM port mode
>>
>> 3. usb-devices outputs after running with this patch:
>> T:  Bus=02 Lev=01 Prnt=01 Port=05 Cnt=01 Dev#= 48 Spd=480 MxCh= 0
>> D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
>> P:  Vendor=0e8d ProdID=00a1 Rev=02.00
>> S:  Manufacturer=MediaTek Inc
>> S:  Product=Product
>> C:  #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA
>> I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
>> I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
>> I:  If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
>>
>> 4. patch based on branch:
>>       git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>>
>>
>> Signed-off-by: Meng Zhang <meng.zhang@mediatek.com>
>
> Nowadays, aren't such things handled in userspace by the usb_modeswitch program rather than in the kernel driver?
>
> Alan Stern
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Matthew Dharm
Maintainer, USB Mass Storage driver for Linux

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
  2012-02-29  4:07     ` Matthew Dharm
@ 2012-02-29  6:03       ` Meng Zhang (张萌)
  2012-02-29  6:46         ` Matthew Dharm
  2012-02-29  7:28         ` Josua Dietze
  0 siblings, 2 replies; 11+ messages in thread
From: Meng Zhang (张萌) @ 2012-02-29  6:03 UTC (permalink / raw)
  To: Matthew Dharm
  Cc: Alan Stern, Josua Dietze, Phil Dibowitz, USB list,
	USB Storage list, Kernel development list

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 3389 bytes --]

Hi Matthew,

Thanks for your comment, I've tested some other products and found their entries in /lib/udev/rules.d/40-usb_modeswitch.rules.
So, does usb_modeswitch comes with latest distributions by default? 

Thanks!

BR.
Meng Zhang


-----Original Message-----
From: Matthew Dharm [mailto:mdharm-usb@one-eyed-alien.net] 
Sent: Wednesday, February 29, 2012 12:08 PM
To: Meng Zhang (ÕÅÃÈ)
Cc: Alan Stern; Josua Dietze; Phil Dibowitz; USB list; USB Storage list; Kernel development list
Subject: Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry

Devices should not be added to unusual_devs.h unless the device CANNOT use the usb_modeswitch method.  This most commonly applies when the device's usb-storage emulation is poor, and the probing commands sent by usb-storage cause the device to crash.

It is much more convenient for users to just upgrade their usb_modeswitch utility than it is for them to upgrade a kernel, which is much more difficult and much more rare.  As for 'input command manually', that is what udev scripts are for.

If this can be handled from userspace by usb_modeswitch, then that is where it should be done.

Matt

2012/2/28 Meng Zhang (ÕÅÃÈ) <Meng.Zhang@mediatek.com>:
> Hi Alan,
>
> As far as I know, many other devices used this init function in unusual_devs.h for their "ZeroCD" feature, and I think this is more convenient than let device user install utilities like usb_modeswitch and input command manually.
>
> Thanks.
>
> BR.
> Meng Zhang
>
> -----Original Message-----
> From: linux-usb-owner@vger.kernel.org 
> [mailto:linux-usb-owner@vger.kernel.org] On Behalf Of Alan Stern
> Sent: Tuesday, February 28, 2012 11:31 PM
> To: Meng Zhang (ÕÅÃÈ)
> Cc: Josua Dietze; Matthew Dharm; Phil Dibowitz; USB list; USB Storage 
> list; Kernel development list
> Subject: Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device 
> entry
>
> On Tue, 28 Feb 2012, Meng Zhang wrote:
>
>> from: Meng Zhang <meng.zhang@mediatek.com>
>>
>> 1. Add entrys for mediatek MT6276M in unusual_devs.h
>>
>> 2. Add init function for mediatek MT6276M to switch to COM port mode
>>
>> 3. usb-devices outputs after running with this patch:
>> T:  Bus=02 Lev=01 Prnt=01 Port=05 Cnt=01 Dev#= 48 Spd=480 MxCh= 0
>> D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
>> P:  Vendor=0e8d ProdID=00a1 Rev=02.00
>> S:  Manufacturer=MediaTek Inc
>> S:  Product=Product
>> C:  #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA
>> I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
>> I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
>> I:  If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
>>
>> 4. patch based on branch:
>>       
>> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>>
>>
>> Signed-off-by: Meng Zhang <meng.zhang@mediatek.com>
>
> Nowadays, aren't such things handled in userspace by the usb_modeswitch program rather than in the kernel driver?
>
> Alan Stern
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" 
> in the body of a message to majordomo@vger.kernel.org More majordomo 
> info at  http://vger.kernel.org/majordomo-info.html



--
Matthew Dharm
Maintainer, USB Mass Storage driver for Linux
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
  2012-02-29  6:03       ` Meng Zhang (张萌)
@ 2012-02-29  6:46         ` Matthew Dharm
  2012-02-29  7:28         ` Josua Dietze
  1 sibling, 0 replies; 11+ messages in thread
From: Matthew Dharm @ 2012-02-29  6:46 UTC (permalink / raw)
  To: Meng Zhang (张萌)
  Cc: Alan Stern, Josua Dietze, Phil Dibowitz, USB list,
	USB Storage list, Kernel development list

My understanding is that usb_modeswitch is part of most distributions,
but that is really a question for the distro guys...

Matt

2012/2/28 Meng Zhang (张萌) <Meng.Zhang@mediatek.com>:
> Hi Matthew,
>
> Thanks for your comment, I've tested some other products and found their entries in /lib/udev/rules.d/40-usb_modeswitch.rules.
> So, does usb_modeswitch comes with latest distributions by default?
>
> Thanks!
>
> BR.
> Meng Zhang
>
>
> -----Original Message-----
> From: Matthew Dharm [mailto:mdharm-usb@one-eyed-alien.net]
> Sent: Wednesday, February 29, 2012 12:08 PM
> To: Meng Zhang (张萌)
> Cc: Alan Stern; Josua Dietze; Phil Dibowitz; USB list; USB Storage list; Kernel development list
> Subject: Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
>
> Devices should not be added to unusual_devs.h unless the device CANNOT use the usb_modeswitch method.  This most commonly applies when the device's usb-storage emulation is poor, and the probing commands sent by usb-storage cause the device to crash.
>
> It is much more convenient for users to just upgrade their usb_modeswitch utility than it is for them to upgrade a kernel, which is much more difficult and much more rare.  As for 'input command manually', that is what udev scripts are for.
>
> If this can be handled from userspace by usb_modeswitch, then that is where it should be done.
>
> Matt
>
> 2012/2/28 Meng Zhang (张萌) <Meng.Zhang@mediatek.com>:
>> Hi Alan,
>>
>> As far as I know, many other devices used this init function in unusual_devs.h for their "ZeroCD" feature, and I think this is more convenient than let device user install utilities like usb_modeswitch and input command manually.
>>
>> Thanks.
>>
>> BR.
>> Meng Zhang
>>
>> -----Original Message-----
>> From: linux-usb-owner@vger.kernel.org
>> [mailto:linux-usb-owner@vger.kernel.org] On Behalf Of Alan Stern
>> Sent: Tuesday, February 28, 2012 11:31 PM
>> To: Meng Zhang (张萌)
>> Cc: Josua Dietze; Matthew Dharm; Phil Dibowitz; USB list; USB Storage
>> list; Kernel development list
>> Subject: Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device
>> entry
>>
>> On Tue, 28 Feb 2012, Meng Zhang wrote:
>>
>>> from: Meng Zhang <meng.zhang@mediatek.com>
>>>
>>> 1. Add entrys for mediatek MT6276M in unusual_devs.h
>>>
>>> 2. Add init function for mediatek MT6276M to switch to COM port mode
>>>
>>> 3. usb-devices outputs after running with this patch:
>>> T:  Bus=02 Lev=01 Prnt=01 Port=05 Cnt=01 Dev#= 48 Spd=480 MxCh= 0
>>> D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
>>> P:  Vendor=0e8d ProdID=00a1 Rev=02.00
>>> S:  Manufacturer=MediaTek Inc
>>> S:  Product=Product
>>> C:  #Ifs= 3 Cfg#= 1 Atr=80 MxPwr=500mA
>>> I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
>>> I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
>>> I:  If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
>>>
>>> 4. patch based on branch:
>>>
>>> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>>>
>>>
>>> Signed-off-by: Meng Zhang <meng.zhang@mediatek.com>
>>
>> Nowadays, aren't such things handled in userspace by the usb_modeswitch program rather than in the kernel driver?
>>
>> Alan Stern
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-usb"
>> in the body of a message to majordomo@vger.kernel.org More majordomo
>> info at  http://vger.kernel.org/majordomo-info.html
>
>
>
> --
> Matthew Dharm
> Maintainer, USB Mass Storage driver for Linux



-- 
Matthew Dharm
Maintainer, USB Mass Storage driver for Linux

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry
  2012-02-29  6:03       ` Meng Zhang (张萌)
  2012-02-29  6:46         ` Matthew Dharm
@ 2012-02-29  7:28         ` Josua Dietze
  1 sibling, 0 replies; 11+ messages in thread
From: Josua Dietze @ 2012-02-29  7:28 UTC (permalink / raw)
  To: "Meng Zhang (张萌)"
  Cc: Matthew Dharm, Alan Stern, Phil Dibowitz, USB list,
	USB Storage list, Kernel development list

Am 29.02.2012 07:03, schrieb Meng Zhang:
> Thanks for your comment, I've tested some other products and found
> their entries in /lib/udev/rules.d/40-usb_modeswitch.rules. So, does
> usb_modeswitch comes with latest distributions by default?

Yes, it does. In most cases it is a prerequisite of Network Manager AFAIK.

The most-used mode switch entry in unusual_devs.h is there for 
historical reasons, from a time when usb_modeswitch was not included 
with distributions yet. I'm talking about "usb_stor_huawei_e220_init".

If people want to access the installer drive for some reason, it's not 
possible if the kernel does the mode switch without giving a choice.
With usb_modeswitch, it's a matter of a small configuration edit.

Josua Dietze

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-02-29  7:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-29  2:37 [PATCH] USB: Mass Storage: Add MediaTek MT6276M device entry Meng Zhang
  -- strict thread matches above, loose matches on Subject: below --
2012-02-28  9:08 Meng Zhang
2012-02-28 11:38 ` Sergei Shtylyov
2012-02-28 11:59   ` Meng Zhang (张萌)
2012-02-29  0:45     ` Meng Zhang (张萌)
2012-02-28 15:30 ` Alan Stern
2012-02-29  0:25   ` Meng Zhang (张萌)
2012-02-29  4:07     ` Matthew Dharm
2012-02-29  6:03       ` Meng Zhang (张萌)
2012-02-29  6:46         ` Matthew Dharm
2012-02-29  7:28         ` Josua Dietze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox