usb: r8a66597-hcd: use platform_data instead of module_param
PATCH v2 1/1 usb: r8a66597-hcd: use platform_data instead of module_param
CPU/board specific parameters (PLL clock, vif etc...) can be set by platform_data instead of module_param.
v2: remove irq_sense member in platform_data because it can OR in
IRQF_TRIGGER_LOW or IRQF_TRIGGER_FALLING against IORESOURCE_IRQ in the struct resource.
--- drivers/usb/host/r8a66597-hcd.c | 60 +++++++++----------------------------- drivers/usb/host/r8a66597.h | 38 ++++++++++++++++++++++-- include/linux/usb/r8a66597.h | 44 ++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 50 deletions(-) create mode 100644 include/linux/usb/r8a66597.h
drivers/usb/host/r8a66597-hcd.c +14 -46
@@ -46,31 +46,10 @@ MODULE_LICENSE("GPL");MODULE_AUTHOR ("Yoshihiro Shimoda" );MODULE_ALIAS ("platform:r8a66597_hcd" ); -#define DRIVER_VERSION "10 Apr 2008" +#define DRIVER_VERSION "2009-05-26"static const char hcd_name[] ="r8a66597_hcd" ; -/* module parameters */ -#if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597 ) -static unsigned short clock =XTAL12 ; -module_param (clock, ushort,0644 ); -MODULE_PARM_DESC (clock,"input clock: 48MHz2768, 24MHz384, 12MHz=0 " -"(default=0)" ); -#endif - -static unsigned short vif =LDRV ; -module_param (vif, ushort,0644 ); -MODULE_PARM_DESC (vif,"input VIF: 3.3V2768, 1.5V=0(default2768)" ); - -static unsigned short endian; -module_param (endian, ushort,0644 ); -MODULE_PARM_DESC (endian,"data endian: big%6, little=0 (default=0)" ); - -static unsigned short irq_sense =0xff ; -module_param (irq_sense, ushort,0644 ); -MODULE_PARM_DESC (irq_sense,"IRQ sense: low level2, falling edge=0 " -"(default2)" ); -static void packet_write (struct r8a66597 *r8a66597,u16 pipenum);static int r8a66597_get_frame (struct usb_hcd *hcd);
@@ -136,7 +115,8 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) } }while ((tmp &USBE ) !=USBE );r8a66597_bclr (r8a66597,USBE ,SYSCFG0 ); -r8a66597_mdfy (r8a66597, clock,XTAL ,SYSCFG0 ); +r8a66597_mdfy (r8a66597,get_xtal_from_pdata (r8a66597->pdata),XTAL , +SYSCFG0 ); i =0 ;r8a66597_bset (r8a66597,XCKE ,SYSCFG0 );
@@ -203,6 +183,9 @@ static void r8a66597_disable_port(struct r8a66597 *r8a66597, int port)static int enable_controller (struct r8a66597 *r8a66597) {int ret, port; +u16 vif = r8a66597->pdata->vif ?LDRV :0 ; +u16 irq_sense = r8a66597->irq_sense_low ?INTL :0 ; +u16 endian = r8a66597->pdata->endian ?BIGEND :0 ; ret =r8a66597_clock_enable (r8a66597);if (ret <0 )
@@ -2418,6 +2401,12 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) goto clean_up; } +if (pdev->dev.platform_data =NULL ) { +dev_err (&pdev->dev,"no platform data\n" ); + ret = -ENODEV ; + goto clean_up; + } +/* initialize hcd */ hcd =usb_create_hcd (&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name);if (!hcd) {
@@ -2428,6 +2417,8 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) r8a66597 =hcd_to_r8a66597 (hcd);memset (r8a66597,0 ,sizeof (struct r8a66597 ));dev_set_drvdata (&pdev->dev, r8a66597); + r8a66597->pdata = pdev->dev.platform_data; + r8a66597->irq_sense_low = irq_trigger =IRQF_TRIGGER_LOW ;#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597 ) && defined(CONFIG_HAVE_CLK )snprintf (clk_name,sizeof (clk_name),"usb%d" , pdev->id);
@@ -2458,29 +2449,6 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) hcd->rsrc_start = res->start; -/* irq_sense setting on cmdline takes precedence over resource -* settings, so the introduction of irqflags in IRQ resourse -* won't disturb existing setups */ -switch (irq_sense) { -case INTL : - irq_trigger =IRQF_TRIGGER_LOW ; -break ; -case 0 : - irq_trigger =IRQF_TRIGGER_FALLING ; -break ; -case 0xff : -if (irq_trigger) - irq_sense = (irq_trigger &IRQF_TRIGGER_LOW ) ? -INTL :0 ; -else { - irq_sense =INTL ; - irq_trigger =IRQF_TRIGGER_LOW ; - } -break ; -default : -dev_err (&pdev->dev,"Unknown irq_sense value.\n" ); - } - ret =usb_add_hcd (hcd, irq,IRQF_DISABLED | irq_trigger);if (ret !=0 ) {dev_err (&pdev->dev,"Failed to add hcd\n" );
drivers/usb/host/r8a66597.h +34 -4
@@ -30,6 +30,8 @@#include <linux/clk.h> #endif +#include <linux/usb/r8a66597.h> +#define SYSCFG0 0x00#define SYSCFG1 0x02#define SYSSTS0 0x04
@@ -488,6 +490,7 @@ struct r8a66597 {#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597 ) && defined(CONFIG_HAVE_CLK )struct clk *clk;#endif +struct r8a66597_platdata *pdata;struct r8a66597_device device0;struct r8a66597_root_hub root_hub[R8A66597_MAX_ROOT_HUB ];struct list_head pipe_queue[R8A66597_MAX_NUM_PIPE ];
@@ -506,6 +509,7 @@ struct r8a66597 {unsigned long child_connect_map[4 ]; unsigned bus_suspended:1; + unsigned irq_sense_low:1; };static inline struct r8a66597 *hcd_to_r8a66597 (struct usb_hcd *hcd)
@@ -660,10 +664,36 @@ static inline void r8a66597_port_power(struct r8a66597 *r8a66597, int port, {unsigned long dvstctr_reg =get_dvstctr_reg (port); -if (power) -r8a66597_bset (r8a66597,VBOUT , dvstctr_reg); -else -r8a66597_bclr (r8a66597,VBOUT , dvstctr_reg); +if (r8a66597->pdata->port_power) { + r8a66597->pdata->port_power (port, power); + }else { +if (power) +r8a66597_bset (r8a66597,VBOUT , dvstctr_reg); +else +r8a66597_bclr (r8a66597,VBOUT , dvstctr_reg); + } +} + +static inline u16 get_xtal_from_pdata (struct r8a66597_platdata *pdata) +{ +u16 clock =0 ; + +switch (pdata->xtal) { +case R8A66597_PLATDATA_XTAL_12MHZ : + clock =XTAL12 ; +break ; +case R8A66597_PLATDATA_XTAL_24MHZ : + clock =XTAL24 ; +break ; +case R8A66597_PLATDATA_XTAL_48MHZ : + clock =XTAL48 ; +break ; +default : +printk (KERN_ERR "r8a66597: platdata clock is wrong.\n" ); +break ; + } + +return clock; }#define get_pipectr_addr (pipenum) (PIPE1CTR + (pipenum - 1) * 2)
include/linux/usb/r8a66597.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
1.5.5
Quoted 8 lines · Yoshihiro Shimoda
CPU/board specific parameters (PLL clock, vif etc...) can be set by
platform_datainstead ofmodule_param.v2: remove
irq_sensemember inplatform_databecause it can OR in
IRQF_TRIGGER_LOWorIRQF_TRIGGER_FALLINGagainstIORESOURCE_IRQin the struct resource.Signed-off-by Yoshihiro Shimoda <[email protected]>
Looks better!
Re: [PATCH v2] usb: r8a66597-hcd: use platform_data instead of
In reply to Yoshihiro ShimodaHi Paul,
Quoted 8 lines · Paul Mundt
Quoted 7 lines · Yoshihiro Shimoda
CPU/board specific parameters (PLL clock, vif etc...) can be set by
platform_datainstead ofmodule_param.v2: remove
irq_sensemember inplatform_databecause it can OR in
IRQF_TRIGGER_LOWorIRQF_TRIGGER_FALLINGagainstIORESOURCE_IRQin the struct resource.
Quoted 6 lines
Quoted 1 line
Signed-off-by Yoshihiro Shimoda <[email protected]>Looks better!
Reviewed-by Paul Mundt <[email protected]>
Thank you very much your review and Reviewed-by.
Thanks,
Yoshihiro Shimoda