ARM: shmobile: kzm9g: add r8a66597_udc support
RFC PATCH 1/1 ARM: shmobile: kzm9g: add r8a66597_udc support
Add r8a66597_udc support for CN6 connector on KZM-A9-GT board. r8a66597 USB controller can not use host mode and peripheral mode at the same time. At default r8a66597_udc is disabled. To use r8a66597_udc define USE_R8A66597_UDC.
---
Hello,
This is an experimental patch to test if r8a66597_udc works or not. I think that using r8a66597_udc is very rare because usually r8a66597_hcd is used and they can not use at the same time. So this patch is really for test and I add this patch code is all inside #ifdef USE_R8A66597_UDC.
My question, this kind of test code should not merge to mainline? Or, the define USE_R8A66597_UDC should be change to CONFIG_R8A66597_UDC or so, and it to Kconfig?
arch/arm/mach-shmobile/board-kzm9g.c | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
arch/arm/mach-shmobile/board-kzm9g.c +40 -0
@@ -131,6 +131,37 @@ static struct platform_device usb_host_device = { .resource = usb_resources, }; +#ifdef USE_R8A66597_UDC +static struct r8a66597_platdata usb1_gadget_data = { + .on_chip =0 , + .xtal =R8A66597_PLATDATA_XTAL_48MHZ , +}; + +static struct resource usb1_gadget_resources[] = { + [0 ] = { + .start =0x10010000 , + .end =0x1001ffff -1 , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .start =intcs_evt2irq (0x220 ),/* IRQ1 */ + .flags =IORESOURCE_IRQ , + }, +}; + +static struct platform_device usb1_gadget_device = { + .name ="r8a66597_udc" , + .id =1 ,/* USB1 */ + .dev = { + .dma_mask =NULL ,/* not use dma */ + .coherent_dma_mask =0xffffffff , + .platform_data = &usb1_gadget_data, + }, + .num_resources =ARRAY_SIZE (usb1_gadget_resources), + .resource = usb1_gadget_resources, +}; +#endif +/* USB Func CN17 */ struct usbhs_private {unsigned int phy;
@@ -577,8 +608,17 @@ static struct i2c_board_info i2c3_devices[] = {static struct platform_device *kzm_devices[]__initdata = { &smsc_device, +#ifdef USE_R8A66597_UDC +/* +* Do not enable usb_host_device because r8a66597_udc and r8a66597_hcd +* can not use at the same time. +* Also, do not enable usbhs_device for simplify. +*/ + &usb1_gadget_device, +#else &usb_host_device, &usbhs_device, +#endif &lcdc_device, &mmc_device, &sdhi0_device,
Signature · 1 line
1.7.9.5
Hi Kobayashi-san
Quoted 9 lines
Add
r8a66597_udcsupport for CN6 connector on KZM-A9-GT board. r8a66597 USB controller can not use host mode and peripheral mode at the same time. At defaultr8a66597_udcis disabled. To user8a66597_udcdefineUSE_R8A66597_UDC.Signed-off-by Tetsuyuki Kobayashi <[email protected]>---
Hello,
Quoted 8 lines
This is an experimental patch to test if
r8a66597_udcworks or not. I think that usingr8a66597_udcis very rare because usuallyr8a66597_hcdis used and they can not use at the same time. So this patch is really for test and I add this patch code is all inside #ifdefUSE_R8A66597_UDC.My question, this kind of test code should not merge to mainline? Or, the define
USE_R8A66597_UDCshould be change toCONFIG_R8A66597_UDCor so, and it toKconfig?
I'm not sure the maintainer's opinion,
but if this patch is only for the "test", then #ifdef xx_TEST_xx is better name.
OTOH, if you add "choice" in Kconfig to select UDC/HCD (not for test), it is better for users.
arch/arm/mach-shmobile/board-kzm9g.c static struct i2c_board_info i2c3_devices[] = { · line 621
Quoted 11 lines
arch/arm/mach-shmobile/board-kzm9g.c +9
-0+#ifdef USE_R8A66597_UDC +/* +* Do not enable usb_host_device because r8a66597_udc and r8a66597_hcd +* can not use at the same time. +* Also, do not enable usbhs_device for simplify. +*/ + &usb1_gadget_device, +#else &usb_host_device, &usbhs_device, +#endif
Why is usbhs_device disabled for simplify ?
what's happen if it was enabled ?
Best regards
---
Kuninori Morimoto
Hi Morimoto-san, thank you for comment.
Quoted 18 lines · Kuninori Morimoto
Quoted 9 lines
Add
r8a66597_udcsupport for CN6 connector on KZM-A9-GT board. r8a66597 USB controller can not use host mode and peripheral mode at the same time. At defaultr8a66597_udcis disabled. To user8a66597_udcdefineUSE_R8A66597_UDC.Signed-off-by Tetsuyuki Kobayashi <[email protected]>---
Hello,Quoted 8 lines
This is an experimental patch to test if
r8a66597_udcworks or not. I think that usingr8a66597_udcis very rare because usuallyr8a66597_hcdis used and they can not use at the same time. So this patch is really for test and I add this patch code is all inside #ifdefUSE_R8A66597_UDC.My question, this kind of test code should not merge to mainline? Or, the define
USE_R8A66597_UDCshould be change toCONFIG_R8A66597_UDCor so, and it toKconfig?
Quoted 6 lines
I'm not sure the maintainer's opinion,
but if this patch is only for the "test", then #ifdefxx_TEST_xxis better name.OTOH, if you add "choice" in
Kconfigto select UDC/HCD (not for test), it is better for users.
Now in my mind, I will choose the latter. KZM-A9-GT is an *evaluation* board, so someone want to evaluate R8A66597_UDC.
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-shmobile/board-kzm9g.c +6
-0+#ifdef USE_R8A66597_UDC +/* +* Do not enable usb_host_device because r8a66597_udc and r8a66597_hcd +* can not use at the same time. +* Also, do not enable usbhs_device for simplify. +*/
Quoted 9 lines
arch/arm/mach-shmobile/board-kzm9g.c static struct i2c_board_info i2c3_devices[] = { · line 621
Quoted 5 lines
arch/arm/mach-shmobile/board-kzm9g.c +3
-0+ &usb1_gadget_device, +#else &usb_host_device, &usbhs_device, +#endifWhy is
usbhs_devicedisabled for simplify ?
what's happen if it was enabled ?
If the board has only one USB gadget, it is simple and almost board has only one USB gadget.
But I don't understand yet how it works if the board has 2 or more USB devices. Is it possible one for mass storage and the other for ethernet over USB, or so?
Hi Kobayashi-san
Quoted 8 lines
Quoted 6 lines
I'm not sure the maintainer's opinion,
but if this patch is only for the "test", then #ifdefxx_TEST_xxis better name.OTOH, if you add "choice" in
Kconfigto select UDC/HCD (not for test), it is better for users.Now in my mind, I will choose the latter. KZM-A9-GT is an *evaluation* board, so someone want to evaluate
R8A66597_UDC.
cool !
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-shmobile/board-kzm9g.c +6
-0+#ifdef USE_R8A66597_UDC +/* +* Do not enable usb_host_device because r8a66597_udc and r8a66597_hcd +* can not use at the same time. +* Also, do not enable usbhs_device for simplify. +*/ Quoted 8 lines
arch/arm/mach-shmobile/board-kzm9g.c static struct i2c_board_info i2c3_devices[] = { · line 621
Quoted 5 lines
arch/arm/mach-shmobile/board-kzm9g.c +3
-0+ &usb1_gadget_device, +#else &usb_host_device, &usbhs_device, +#endifWhy is
usbhs_devicedisabled for simplify ?
what's happen if it was enabled ?
Quoted 5 lines
If the board has only one USB gadget, it is simple and almost board has only one USB gadget.
But I don't understand yet how it works if the board has 2 or more USB devices. Is it possible one for mass storage and the other for ethernet over USB, or so?
I think so on latest kernel. (old kernel didn't support it)
I forgot detail of it, but 2usb-gadget worked correctly on other board (= mackerel ?)
Quoted 2 lines
insmod
g_mass_stragefile=xxx
insmodg_ether
If it doesn't work correctly, driver seems broken
# Current kzm9g board is using r8a66597_hcd/udc driver, since renesas_usbhs still doesn't support # "external" chip yet.
# But in the future, it should be switched to use renesas_usbhs instead of r8a66597_xxx.
I don't care if you disabled renesas_usbhs or not. (I don't know maintainer's opinion)
But when you use that style, please care compile warning. I got this
/opt/usr/src/WORK/morimoto/gitlinux/linux-2.6/arch/arm/mach-shmobile/board-kzm9g.c:123:31: warning: 'usb_host_device' defined but not used [-Wunused-variable] /opt/usr/src/WORK/morimoto/gitlinux/linux-2.6/arch/arm/mach-shmobile/board-kzm9g.c:298:31: warning: 'usbhs_device' defined but not used [-Wunused-variable]
Best regards
---
Kuninori Morimoto
Hi Morimoto-san
Quoted 35 lines · Kuninori Morimoto
Hi Kobayashi-san
Quoted 8 lines
Quoted 6 lines
I'm not sure the maintainer's opinion,
but if this patch is only for the "test", then #ifdefxx_TEST_xxis better name.OTOH, if you add "choice" in
Kconfigto select UDC/HCD (not for test), it is better for users.Now in my mind, I will choose the latter. KZM-A9-GT is an *evaluation* board, so someone want to evaluate
R8A66597_UDC.cool !
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
arch/arm/mach-shmobile/board-kzm9g.c +6
-0+#ifdef USE_R8A66597_UDC +/* +* Do not enable usb_host_device because r8a66597_udc and r8a66597_hcd +* can not use at the same time. +* Also, do not enable usbhs_device for simplify. +*/ Quoted 8 lines
arch/arm/mach-shmobile/board-kzm9g.c static struct i2c_board_info i2c3_devices[] = { · line 621
Quoted 5 lines
arch/arm/mach-shmobile/board-kzm9g.c +3
-0+ &usb1_gadget_device, +#else &usb_host_device, &usbhs_device, +#endifWhy is
usbhs_devicedisabled for simplify ?
what's happen if it was enabled ?Quoted 5 lines
If the board has only one USB gadget, it is simple and almost board has only one USB gadget.
But I don't understand yet how it works if the board has 2 or more USB devices. Is it possible one for mass storage and the other for ethernet over USB, or so?
Quoted 6 lines
I think so on latest kernel. (old kernel didn't support it)
I forgot detail of it, but 2usb-gadget worked correctly on other board (= mackerel ?)Quoted 2 lines
insmod
g_mass_stragefile=xxx
insmodg_etherIf it doesn't work correctly, driver seems broken
Thank you. I wanted this kind of information! I will study more.
Quoted 4 lines
# Current kzm9g board is using r8a66597_hcd/udc driver, since
renesas_usbhsstill doesn't support # "external" chip yet.
# But in the future, it should be switched to userenesas_usbhsinstead ofr8a66597_xxx.
Quoted 8 lines
I don't care if you disabled
renesas_usbhsor not. (I don't know maintainer's opinion)
But when you use that style, please care compile warning. I got this
/opt/usr/src/WORK/morimoto/gitlinux/linux-2.6/arch/arm/mach-shmobile/board-kzm9g.c:123:31: warning: 'usb_host_device' defined but not used [-Wunused-variable]/opt/usr/src/WORK/morimoto/gitlinux/linux-2.6/arch/arm/mach-shmobile/board-kzm9g.c:298:31: warning: 'usbhs_device' defined but not used [-Wunused-variable]
Thank you for trying my patch.
Yes. I will take care of them.
Quoted 9 lines · Tetsuyuki Kobayashi
Add
r8a66597_udcsupport for CN6 connector on KZM-A9-GT board. r8a66597 USB controller can not use host mode and peripheral mode at the same time. At defaultr8a66597_udcis disabled. To user8a66597_udcdefineUSE_R8A66597_UDC.Signed-off-by Tetsuyuki Kobayashi <[email protected]>---
Hello,
Quoted 8 lines
This is an experimental patch to test if
r8a66597_udcworks or not. I think that usingr8a66597_udcis very rare because usuallyr8a66597_hcdis used and they can not use at the same time. So this patch is really for test and I add this patch code is all inside #ifdefUSE_R8A66597_UDC.My question, this kind of test code should not merge to mainline? Or, the define
USE_R8A66597_UDCshould be change toCONFIG_R8A66597_UDCor so, and it toKconfig?
Hi Kobayashi-san,
my opinion is that this kind of code should be merged into mainline and that a run-time switch or or more likely Kconfig options should be in place to ensure that hdc and udc can't run at the same time.
Paul, do you have an opinion on this?
Quoted 67 lines
arch/arm/mach-shmobile/board-kzm9g.c | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)arch/arm/mach-shmobile/board-kzm9g.c +40
-0@@ -131,6 +131,37 @@ static struct platform_device usb_host_device = { .resource = usb_resources, }; +#ifdef USE_R8A66597_UDC +static struct r8a66597_platdata usb1_gadget_data = { + .on_chip =0 , + .xtal =R8A66597_PLATDATA_XTAL_48MHZ , +}; + +static struct resource usb1_gadget_resources[] = { + [0 ] = { + .start =0x10010000 , + .end =0x1001ffff -1 , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .start =intcs_evt2irq (0x220 ),/* IRQ1 */ + .flags =IORESOURCE_IRQ , + }, +}; + +static struct platform_device usb1_gadget_device = { + .name ="r8a66597_udc" , + .id =1 ,/* USB1 */ + .dev = { + .dma_mask =NULL ,/* not use dma */ + .coherent_dma_mask =0xffffffff , + .platform_data = &usb1_gadget_data, + }, + .num_resources =ARRAY_SIZE (usb1_gadget_resources), + .resource = usb1_gadget_resources, +}; +#endif +/* USB Func CN17 */ struct usbhs_private {unsigned int phy;@@ -577,8 +608,17 @@ static struct i2c_board_info i2c3_devices[] = {static struct platform_device *kzm_devices[]__initdata = { &smsc_device, +#ifdef USE_R8A66597_UDC +/* +* Do not enable usb_host_device because r8a66597_udc and r8a66597_hcd +* can not use at the same time. +* Also, do not enable usbhs_device for simplify. +*/ + &usb1_gadget_device, +#else &usb_host_device, &usbhs_device, +#endif &lcdc_device, &mmc_device, &sdhi0_device,Signature · 1 line
1.7.9.5
(Resending due to mail server silliness, apologies for any duplicates)
Quoted 19 lines · Simon Horman
Quoted 9 lines · Tetsuyuki Kobayashi
Add
r8a66597_udcsupport for CN6 connector on KZM-A9-GT board. r8a66597 USB controller can not use host mode and peripheral mode at the same time. At defaultr8a66597_udcis disabled. To user8a66597_udcdefineUSE_R8A66597_UDC.Signed-off-by Tetsuyuki Kobayashi <[email protected]>---
Hello,Quoted 8 lines
This is an experimental patch to test if
r8a66597_udcworks or not. I think that usingr8a66597_udcis very rare because usuallyr8a66597_hcdis used and they can not use at the same time. So this patch is really for test and I add this patch code is all inside #ifdefUSE_R8A66597_UDC.My question, this kind of test code should not merge to mainline? Or, the define
USE_R8A66597_UDCshould be change toCONFIG_R8A66597_UDCor so, and it toKconfig?
Quoted 8 lines
Hi Kobayashi-san,
my opinion is that this kind of code should be merged into mainline and that a run-time switch or or more likely
Kconfigoptions should be in place to ensure that hdc and udc can't run at the same time.Paul, do you have an opinion on this?
In general the ifdeffery for this should be avoided anyways, whether this means we need to register a dummy gpio or whatever else that can be consumed by both the udc/hcd drivers, ensuring that whoever gets there first succeeds in its probe path.
If you need to put ifdefs in your platform device array, something is horribly wrong in the drivers. ie, there's nothing stopping you from having both built as modules, and you should have no problems switching from one to the other.
Paul, Simon, Thank you for comments.
I will refine this patch using Kconfig option.
Quoted 40 lines · Paul Mundt
(Resending due to mail server silliness, apologies for any duplicates)
Quoted 19 lines · Simon Horman
Quoted 9 lines · Tetsuyuki Kobayashi
Add
r8a66597_udcsupport for CN6 connector on KZM-A9-GT board. r8a66597 USB controller can not use host mode and peripheral mode at the same time. At defaultr8a66597_udcis disabled. To user8a66597_udcdefineUSE_R8A66597_UDC.Signed-off-by Tetsuyuki Kobayashi <[email protected]>---
Hello,Quoted 8 lines
This is an experimental patch to test if
r8a66597_udcworks or not. I think that usingr8a66597_udcis very rare because usuallyr8a66597_hcdis used and they can not use at the same time. So this patch is really for test and I add this patch code is all inside #ifdefUSE_R8A66597_UDC.My question, this kind of test code should not merge to mainline? Or, the define
USE_R8A66597_UDCshould be change toCONFIG_R8A66597_UDCor so, and it toKconfig?Quoted 8 lines
Hi Kobayashi-san,
my opinion is that this kind of code should be merged into mainline and that a run-time switch or or more likely
Kconfigoptions should be in place to ensure that hdc and udc can't run at the same time.Paul, do you have an opinion on this?
In general the ifdeffery for this should be avoided anyways, whether this means we need to register a dummy gpio or whatever else that can be consumed by both the udc/hcd drivers, ensuring that whoever gets there first succeeds in its probe path.
If you need to put ifdefs in your platform device array, something is horribly wrong in the drivers. ie, there's nothing stopping you from having both built as modules, and you should have no problems switching from one to the other.