usb: r8a66597: Remove CONFIG_SUPERH_ON_CHIP_R8A66597
PATCH 1/8 usb: r8a66597: Remove CONFIG_SUPERH_ON_CHIP_R8A66597
Remove CONFIG_SUPERH_ON_CHIP_R8A66597 macro, which is unused.
--- drivers/usb/host/r8a66597-hcd.c | 14 -------------- drivers/usb/host/r8a66597.h | 12 ++---------- 2 files changed, 2 insertions(+), 24 deletions(-)
drivers/usb/host/r8a66597-hcd.c +0 -14
@@ -61,17 +61,6 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)u16 tmp;int i =0 ; -#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) - do { - r8a66597_write(r8a66597, SCKE, SYSCFG0); - tmp = r8a66597_read(r8a66597, SYSCFG0); - if (i++ > 1000) { - printf("register access fail.\n"); - return -1; - } - } while ((tmp & SCKE) != SCKE); - r8a66597_write(r8a66597, 0x04, 0x02); -#else do { r8a66597_write(r8a66597, USBE, SYSCFG0); tmp = r8a66597_read(r8a66597, SYSCFG0);
@@ -108,7 +97,6 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)mdelay (1 );r8a66597_bset (r8a66597,SUSPM ,SUSPMODE0 );#endif /* CONFIG_RZA_USB */ -#endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */ return 0 ; }
@@ -118,11 +106,9 @@ static void r8a66597_clock_disable(struct r8a66597 *r8a66597)#if !defined(CONFIG_RZA_USB )r8a66597_bclr (r8a66597,SCKE ,SYSCFG0 );udelay (1 ); -#if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597 )r8a66597_bclr (r8a66597,PLLC ,SYSCFG0 );r8a66597_bclr (r8a66597,XCKE ,SYSCFG0 );r8a66597_bclr (r8a66597,USBE ,SYSCFG0 ); -#endif #else r8a66597_bclr (r8a66597,SUSPM ,SUSPMODE0 );
drivers/usb/host/r8a66597.h +2 -10
@@ -178,15 +178,11 @@#define REW 0x4000/* b14: Buffer rewind */ #define DCLRM 0x2000/* b13: DMA buffer clear mode */ #define DREQE 0x1000/* b12: DREQ output enable */ -#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597 ) -#define MBW 0x0800 -#else #if !defined(CONFIG_RZA_USB )#define MBW 0x0400/* b10: Maximum bit width for FIFO access */ #else #define MBW 0x0800/* b10: Maximum bit width for FIFO access */ #endif -#endif #define MBW_8 0x0000/* 8bit */ #define MBW_16 0x0400/* 16bit */ #define MBW_32 0x0800/* 32bit */
@@ -398,11 +394,7 @@#define R8A66597_MAX_NUM_PIPE 10#define R8A66597_BUF_BSIZE 8#define R8A66597_MAX_DEVICE 10 -#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597 ) -#define R8A66597_MAX_ROOT_HUB 1 -#else #define R8A66597_MAX_ROOT_HUB 2 -#endif #define R8A66597_MAX_SAMPLING 5#define R8A66597_RH_POLL_TIME 10
@@ -435,7 +427,7 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597, int len) {int i; -#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597 ) || defined(CONFIG_RZA_USB ) +#if defined(CONFIG_RZA_USB )unsigned long fifoaddr = r8a66597->reg + offset;unsigned long count;unsigned long *p = buf;
@@ -469,7 +461,7 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, {int i;unsigned long fifoaddr = r8a66597->reg + offset; -#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597 ) || defined(CONFIG_RZA_USB ) +#if defined(CONFIG_RZA_USB )unsigned long count;unsigned char *pb;unsigned long *p = buf;
Signature · 1 line
2.20.1
PATCH 2/8 usb: r8a66597: Make CONFIG_RZA_USB default
No other platforms use this r8a66597 controller but RZ/A1, make RZ/A1 support the default and drop all the other SoC support to remove ifdeffery.
--- drivers/usb/host/r8a66597-hcd.c | 35 ----------------------------- drivers/usb/host/r8a66597.h | 39 --------------------------------- 2 files changed, 74 deletions(-)
drivers/usb/host/r8a66597-hcd.c +0 -35
@@ -70,20 +70,6 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) } }while ((tmp &USBE ) !=USBE );r8a66597_bclr (r8a66597,USBE ,SYSCFG0 ); -#if !defined(CONFIG_RZA_USB ) -r8a66597_mdfy (r8a66597,CONFIG_R8A66597_XTAL ,XTAL ,SYSCFG0 ); - - i =0 ; -r8a66597_bset (r8a66597,XCKE ,SYSCFG0 ); -do { -udelay (1000 ); - tmp =r8a66597_read (r8a66597,SYSCFG0 ); -if (i++ >500 ) { -printf ("register access fail.\n" ); -return -1 ; - } - }while ((tmp &SCKE ) !=SCKE ); -#else /* * RZ/A Only: * Bits XTAL(UCKSEL) and UPLLE in SYSCFG0 for USB0 controls both USB0
@@ -96,28 +82,18 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)setbits (le16,R8A66597_BASE0 ,UPLLE );mdelay (1 );r8a66597_bset (r8a66597,SUSPM ,SUSPMODE0 ); -#endif /* CONFIG_RZA_USB */ return 0 ; }static void r8a66597_clock_disable (struct r8a66597 *r8a66597) { -#if !defined(CONFIG_RZA_USB ) -r8a66597_bclr (r8a66597,SCKE ,SYSCFG0 ); -udelay (1 ); -r8a66597_bclr (r8a66597,PLLC ,SYSCFG0 ); -r8a66597_bclr (r8a66597,XCKE ,SYSCFG0 ); -r8a66597_bclr (r8a66597,USBE ,SYSCFG0 ); -#else r8a66597_bclr (r8a66597,SUSPM ,SUSPMODE0 );clrbits (le16,R8A66597_BASE0 ,UPLLE );mdelay (1 );r8a66597_bclr (r8a66597,USBE ,SYSCFG0 );mdelay (1 ); - -#endif }static void r8a66597_enable_port (struct r8a66597 *r8a66597,int port)
@@ -127,10 +103,6 @@ static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port) val = port ?DRPD :DCFM |DRPD ;r8a66597_bset (r8a66597, val,get_syscfg_reg (port));r8a66597_bset (r8a66597,HSE ,get_syscfg_reg (port)); - -#if !defined(CONFIG_RZA_USB ) -r8a66597_write (r8a66597,BURST |CPU_ADR_RD_WR ,get_dmacfg_reg (port)); -#endif }static void r8a66597_disable_port (struct r8a66597 *r8a66597,int port)
@@ -160,9 +132,6 @@ static int enable_controller(struct r8a66597 *r8a66597)if (ret <0 )return ret; -#if !defined(CONFIG_RZA_USB ) -r8a66597_bset (r8a66597,CONFIG_R8A66597_LDRV &LDRV ,PINCFG ); -#endif r8a66597_bset (r8a66597,USBE ,SYSCFG0 );r8a66597_bset (r8a66597,INTL ,SOFCFG );
@@ -280,16 +249,13 @@ static int send_setup_packet(struct r8a66597 *r8a66597, struct usb_device *dev,unsigned long setup_addr =USBREQ ;u16 intsts1;int timeout =3000 ; -#if defined(CONFIG_RZA_USB )u16 dcpctr; -#endif u16 devsel = setup->request ==USB_REQ_SET_ADDRESS ?0 : dev->devnum;r8a66597_write (r8a66597,make_devsel (devsel) | (8 << dev->maxpacketsize),DCPMAXP );r8a66597_write (r8a66597, ~(SIGN |SACK ),INTSTS1 ); -#if defined(CONFIG_RZA_USB ) dcpctr =r8a66597_read (r8a66597,DCPCTR );if ((dcpctr &PID ) ==PID_BUF ) { if (readw_poll_timeout(r8a66597->reg + DCPCTR, dcpctr,
@@ -298,7 +264,6 @@ static int send_setup_packet(struct r8a66597 *r8a66597, struct usb_device *dev,return -ETIMEDOUT ; } } -#endif for (i =0 ; i <4 ; i++) {r8a66597_write (r8a66597,le16_to_cpu (p[i]), setup_addr);
drivers/usb/host/r8a66597.h +0 -39
@@ -89,27 +89,14 @@#define SUSPMODE0 0x102/* RZ/A only */ /* System Configuration Control Register */ -#if !defined(CONFIG_RZA_USB ) -#define XTAL 0xC000/* b15-14: Crystal selection */ -#define XTAL48 0x8000/* 48MHz */ -#define XTAL24 0x4000/* 24MHz */ -#define XTAL12 0x0000/* 12MHz */ -#define XCKE 0x2000/* b13: External clock enable */ -#define PLLC 0x0800/* b11: PLL control */ -#define SCKE 0x0400/* b10: USB clock enable */ -#define PCSDIS 0x0200/* b9: not CS wakeup */ -#define LPSME 0x0100/* b8: Low power sleep mode */ -#endif #define HSE 0x0080/* b7: Hi-speed enable */ #define DCFM 0x0040/* b6: Controller function select */ #define DRPD 0x0020/* b5: D+/- pull down control */ #define DPRPU 0x0010/* b4: D+ pull up control */ -#if defined(CONFIG_RZA_USB )#define XTAL 0x0004/* b2: Crystal selection */ #define XTAL12 0x0004/* 12MHz */ #define XTAL48 0x0000/* 48MHz */ #define UPLLE 0x0002/* b1: internal PLL control */ -#endif #define USBE 0x0001/* b0: USB module operation enable */ /* System Configuration Status Register */
@@ -178,11 +165,7 @@#define REW 0x4000/* b14: Buffer rewind */ #define DCLRM 0x2000/* b13: DMA buffer clear mode */ #define DREQE 0x1000/* b12: DREQ output enable */ -#if !defined(CONFIG_RZA_USB ) -#define MBW 0x0400/* b10: Maximum bit width for FIFO access */ -#else #define MBW 0x0800/* b10: Maximum bit width for FIFO access */ -#endif #define MBW_8 0x0000/* 8bit */ #define MBW_16 0x0400/* 16bit */ #define MBW_32 0x0800/* 32bit */
@@ -427,7 +410,6 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597, int len) {int i; -#if defined(CONFIG_RZA_USB )unsigned long fifoaddr = r8a66597->reg + offset;unsigned long count;unsigned long *p = buf;
@@ -440,13 +422,6 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597,unsigned long tmp =inl (fifoaddr);memcpy ((unsigned char *)buf + count *4 , &tmp, len &0x03 ); } -#else -unsigned short *p = buf; - - len = (len +1 ) /2 ; -for (i =0 ; i < len; i++) - p[i] =inw (r8a66597->reg + offset); -#endif } static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val,
@@ -461,7 +436,6 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, {int i;unsigned long fifoaddr = r8a66597->reg + offset; -#if defined(CONFIG_RZA_USB )unsigned long count;unsigned char *pb;unsigned long *p = buf;
@@ -479,19 +453,6 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,outb (pb[i], fifoaddr +3 - i); } } -#else -int odd = len &0x0001 ; -unsigned short *p = buf; - - len = len /2 ; -for (i =0 ; i < len; i++) -outw (p[i], fifoaddr); - -if (odd) { -unsigned char *pb = (unsigned char *)(buf + len); -outb (*pb, fifoaddr); - } -#endif } static inline void r8a66597_mdfy(struct r8a66597 *r8a66597,
Signature · 1 line
2.20.1
PATCH 3/8 usb: r8a66597: Replace IO accessors
In reply to Marek VasutReplace in{bwl}()/out{bwl}() IO accessors with read{bwl}()/write{bwl}(), to make the driver compile both on SH and ARM.
--- drivers/usb/host/r8a66597.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/usb/host/r8a66597.h +7 -7
@@ -402,7 +402,7 @@ struct r8a66597 {static inline u16 r8a66597_read (struct r8a66597 *r8a66597,unsigned long offset) { -return inw (r8a66597->reg + offset); +return readw (r8a66597->reg + offset); } static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597,
@@ -416,10 +416,10 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597, count = len /4 ;for (i =0 ; i < count; i++) - p[i] =inl (r8a66597->reg + offset); + p[i] =readl (r8a66597->reg + offset);if (len &0x00000003 ) { -unsigned long tmp =inl (fifoaddr); +unsigned long tmp =readl (fifoaddr);memcpy ((unsigned char *)buf + count *4 , &tmp, len &0x03 ); } }
@@ -427,7 +427,7 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597,static inline void r8a66597_write (struct r8a66597 *r8a66597,u16 val,unsigned long offset) { -outw (val, r8a66597->reg + offset); +writew (val, r8a66597->reg + offset); } static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
@@ -442,15 +442,15 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, count = len /4 ;for (i =0 ; i < count; i++) -outl (p[i], fifoaddr); +writel (p[i], fifoaddr);if (len &0x00000003 ) { pb = (unsigned char *)buf + count *4 ;for (i =0 ; i < (len &0x00000003 ); i++) {if (r8a66597_read (r8a66597,CFIFOSEL ) &BIGEND ) -outb (pb[i], fifoaddr + i); +writeb (pb[i], fifoaddr + i);else -outb (pb[i], fifoaddr +3 - i); +writeb (pb[i], fifoaddr +3 - i); } } }
Signature · 1 line
2.20.1
PATCH 4/8 usb: r8a66597: Remove BE support
In reply to Marek VasutWhile the USB controller can work both in LE and BE modes, there is no user for the BE mode, so drop it. If there ever is a user for it, it can be easily re-added back.
--- drivers/usb/host/r8a66597-hcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/host/r8a66597-hcd.c +3 -3
@@ -139,9 +139,9 @@ static int enable_controller(struct r8a66597 *r8a66597)for (port =0 ; port <R8A66597_MAX_ROOT_HUB ; port++)r8a66597_write (r8a66597,0 ,get_intenb_reg (port)); -r8a66597_bset (r8a66597,CONFIG_R8A66597_ENDIAN &BIGEND ,CFIFOSEL ); -r8a66597_bset (r8a66597,CONFIG_R8A66597_ENDIAN &BIGEND ,D0FIFOSEL ); -r8a66597_bset (r8a66597,CONFIG_R8A66597_ENDIAN &BIGEND ,D1FIFOSEL ); +r8a66597_bclr (r8a66597,BIGEND ,CFIFOSEL ); +r8a66597_bclr (r8a66597,BIGEND ,D0FIFOSEL ); +r8a66597_bclr (r8a66597,BIGEND ,D1FIFOSEL );r8a66597_bset (r8a66597,TRNENSEL ,SOFCFG );for (port =0 ; port <R8A66597_MAX_ROOT_HUB ; port++)
Signature · 1 line
2.20.1
PATCH 5/8 usb: r8a66597: Replace R8A66597_BASE0
In reply to Marek VasutReplace R8A66597_BASE0 with proper SYSCFG0 accesses, no functional change.
--- drivers/usb/host/r8a66597-hcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/host/r8a66597-hcd.c +3 -3
@@ -76,10 +76,10 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)* and USB1, so we must always set the USB0 register */ #if (CONFIG_R8A66597_XTAL ==1 ) -setbits (le16,R8A66597_BASE0 ,XTAL ); +r8a66597_bset (r8a66597,XTAL ,SYSCFG0 );#endif mdelay (1 ); -setbits (le16,R8A66597_BASE0 ,UPLLE ); +r8a66597_bset (r8a66597,UPLLE ,SYSCFG0 );mdelay (1 );r8a66597_bset (r8a66597,SUSPM ,SUSPMODE0 );
@@ -90,7 +90,7 @@ static void r8a66597_clock_disable(struct r8a66597 *r8a66597) {r8a66597_bclr (r8a66597,SUSPM ,SUSPMODE0 ); -clrbits (le16,R8A66597_BASE0 ,UPLLE ); +r8a66597_bclr (r8a66597,UPLLE ,SYSCFG0 );mdelay (1 );r8a66597_bclr (r8a66597,USBE ,SYSCFG0 );mdelay (1 );
Signature · 1 line
2.20.1
PATCH 6/8 usb: r8a66597: Convert to USB DM
In reply to Marek VasutConvert the R8A66597 USB driver to DM and add support for DT probing. Drop support for legacy non-DM and non-DT probing, since there are no platform using that.
--- drivers/usb/host/r8a66597-hcd.c | 193 +++++++++++++++++++++----------- 1 file changed, 125 insertions(+), 68 deletions(-)
drivers/usb/host/r8a66597-hcd.c +125 -68
@@ -7,6 +7,7 @@#include <common.h> #include <console.h> +#include <dm.h> #include <usb.h> #include <asm/io.h> #include <linux/iopoll.h>
@@ -19,27 +20,49 @@#define R8A66597_DPRINT (...)#endif -static struct r8a66597 gr8a66597; +static inline struct usb_device *usb_dev_get_parent (struct usb_device *udev) +{ +struct udevice *parent = udev->dev->parent; + +/* +* When called from usb-uclass.c: usb_scan_device() udev->dev points +* to the parent udevice, not the actual udevice belonging to the +* udev as the device is not instantiated yet. +* +* If dev is an usb-bus, then we are called from usb_scan_device() for +* an usb-device plugged directly into the root port, return NULL. +*/ +if (device_get_uclass_id (udev->dev) ==UCLASS_USB ) +return NULL ; + +/* +* If these 2 are not the same we are being called from +* usb_scan_device() and udev itself is the parent. +*/ +if (dev_get_parent_priv (udev->dev) != udev) +return udev; + +/* We are being called normally, use the parent pointer */ +if (device_get_uclass_id (parent) ==UCLASS_USB_HUB ) +return dev_get_parent_priv (parent); + +return NULL ; +}static void get_hub_data (struct usb_device *dev,u16 *hub_devnum,u16 *hubport) { -int i; +struct usb_device *parent =usb_dev_get_parent (dev); *hub_devnum =0 ; *hubport =0 ;/* check a device connected to root_hub */ -if ((dev->parent && dev->parent->devnum ==1 ) || +if ((parent && parent->devnum ==1 ) || (dev->devnum ==1 ))return ; -for (i =0 ; i <USB_MAXCHILDREN ; i++) { -if (dev->parent->children[i] == dev) { - *hub_devnum = (u8 )dev->parent->devnum; - *hubport = i; -return ; - } - } + *hub_devnum = (u8 )parent->devnum; + *hubport = parent->portnr -1 ;printf ("get_hub_data error.\n" ); }
@@ -538,10 +561,11 @@ static int check_usb_device_connecting(struct r8a66597 *r8a66597)#include <usbroothubdes.h> -static int r8a66597_submit_rh_msg (struct usb_device *dev,unsigned long pipe, -void *buffer,int transfer_len,struct devrequest *cmd) +static int r8a66597_submit_rh_msg (struct udevice *udev,struct usb_device *dev, +unsigned long pipe,void *buffer, +int transfer_len,struct devrequest *cmd) { -struct r8a66597 *r8a66597 = &gr8a66597; +struct r8a66597 *r8a66597 =dev_get_priv (udev);int leni = transfer_len;int len =0 ;int stat =0 ;
@@ -609,7 +633,7 @@ static int r8a66597_submit_rh_msg(struct usb_device *dev, unsigned long pipe, }break ;case RH_SET_ADDRESS : - gr8a66597.rh_devnum = wValue; + r8a66597->rh_devnum = wValue;break ;case RH_GET_DESCRIPTOR :switch ((wValue &0xff00 ) >>8 ) {
@@ -705,50 +729,21 @@ static int r8a66597_submit_rh_msg(struct usb_device *dev, unsigned long pipe,return stat; } -int submit_bulk_msg (struct usb_device *dev,unsigned long pipe,void *buffer, -int transfer_len) -{ -struct r8a66597 *r8a66597 = &gr8a66597; -int ret =0 ; - -R8A66597_DPRINT ("%s\n" , __func__); -R8A66597_DPRINT ("pipe = %08x, buffer = %p, len = %d, devnum = %d\n" , - pipe, buffer, transfer_len, dev->devnum); - -set_devadd (r8a66597, dev->devnum, dev,0 ); - -pipe_buffer_setting (r8a66597, dev, pipe); - - dev->act_len =0 ; -while (dev->act_len < transfer_len && ret ==0 ) { -if (ctrlc ()) -return -1 ; - -if (usb_pipein (pipe)) - ret =receive_bulk_packet (r8a66597, dev, pipe, buffer, - transfer_len); -else - ret =send_bulk_packet (r8a66597, dev, pipe, buffer, - transfer_len); - } - -if (ret ==0 ) - dev->status =0 ; - -return ret; -} - -int submit_control_msg (struct usb_device *dev,unsigned long pipe, -void *buffer,int transfer_len,struct devrequest *setup) +static int r8a66597_submit_control_msg (struct udevice *udev,struct usb_device *dev, +unsigned long pipe,void *buffer,int length, +struct devrequest *setup) { -struct r8a66597 *r8a66597 = &gr8a66597; +struct r8a66597 *r8a66597 =dev_get_priv (udev);u16 r8a66597_address = setup->request ==USB_REQ_SET_ADDRESS ?0 : dev->devnum; +debug ("%s: dev='%s', udev=%p, udev->dev='%s', portnr=%d\n" , __func__, + udev->name, dev, dev->dev->name, dev->portnr); +R8A66597_DPRINT ("%s\n" , __func__);if (usb_pipedevice (pipe) == r8a66597->rh_devnum) -return r8a66597_submit_rh_msg (dev, pipe, buffer, transfer_len, - setup); +return r8a66597_submit_rh_msg (udev, dev, pipe, buffer, + length, setup);R8A66597_DPRINT ("%s: setup\n" , __func__);set_devadd (r8a66597, r8a66597_address, dev,0 );
@@ -761,7 +756,7 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, dev->act_len =0 ;if (usb_pipein (pipe))if (receive_control_packet (r8a66597, dev, buffer, - transfer_len) <0 ) + length) <0 )return -1 ;if (send_status_packet (r8a66597, pipe) <0 )
@@ -772,40 +767,102 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe,return 0 ; } -int submit_int_msg (struct usb_device *dev,unsigned long pipe,void *buffer, -int transfer_len,int interval) +static int r8a66597_submit_bulk_msg (struct udevice *udev,struct usb_device *dev, +unsigned long pipe,void *buffer,int length) { -/* no implement */ +struct r8a66597 *r8a66597 =dev_get_priv (udev); +int ret =0 ; + +debug ("%s: dev='%s', udev=%p\n" , __func__, udev->name, dev); +R8A66597_DPRINT ("%s\n" , __func__); -return 0 ; +R8A66597_DPRINT ("pipe = %08x, buffer = %p, len = %d, devnum = %d\n" , + pipe, buffer, length, dev->devnum); + +set_devadd (r8a66597, dev->devnum, dev,0 ); + +pipe_buffer_setting (r8a66597, dev, pipe); + + dev->act_len =0 ; +while (dev->act_len < length && ret ==0 ) { +if (ctrlc ()) +return -1 ; + +if (usb_pipein (pipe)) + ret =receive_bulk_packet (r8a66597, dev, pipe, buffer, + length); +else + ret =send_bulk_packet (r8a66597, dev, pipe, buffer, + length); + } + +if (ret ==0 ) + dev->status =0 ; + +return ret; } -int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) +static int r8a66597_usb_ofdata_to_platdata (struct udevice *dev) { -struct r8a66597 *r8a66597 = &gr8a66597; +struct r8a66597 *priv =dev_get_priv (dev); +fdt_addr_t addr; -R8A66597_DPRINT ("%s\n" , __func__); + addr =dev_read_addr (dev); +if (addr ==FDT_ADDR_T_NONE ) +return -EINVAL ; + priv->reg = addr; -memset (r8a66597,0 ,sizeof (*r8a66597)); - r8a66597->reg =CONFIG_R8A66597_BASE_ADDR ; +return 0 ; +} -disable_controller (r8a66597); +static int r8a66597_usb_probe (struct udevice *dev) +{ +struct r8a66597 *priv =dev_get_priv (dev); +struct usb_bus_priv *bus_priv =dev_get_uclass_priv (dev); + + bus_priv->desc_before_addr = true; + +disable_controller (priv);mdelay (100 ); -enable_controller (r8a66597); -r8a66597_port_power (r8a66597,0 ,1 ); +enable_controller (priv); +r8a66597_port_power (priv,0 ,1 );/* check usb device */ -check_usb_device_connecting (r8a66597); +check_usb_device_connecting (priv);mdelay (50 );return 0 ; } -int usb_lowlevel_stop (int index) +static int r8a66597_usb_remove (struct udevice *dev) { -disable_controller (&gr8a66597); +struct r8a66597 *priv =dev_get_priv (dev); + +disable_controller (priv);return 0 ; } + +struct dm_usb_ops r8a66597_usb_ops = { + .control = r8a66597_submit_control_msg, + .bulk = r8a66597_submit_bulk_msg, +}; + +static const struct udevice_id r8a66597_usb_ids[] = { + { .compatible ="renesas,rza1-usbhs" }, + { } +}; + +U_BOOT_DRIVER (usb_r8a66597) = { + .name ="r8a66597_usb" , + .id =UCLASS_USB , + .of_match = r8a66597_usb_ids, + .ofdata_to_platdata = r8a66597_usb_ofdata_to_platdata, + .probe = r8a66597_usb_probe, + .remove = r8a66597_usb_remove, + .ops = &r8a66597_usb_ops, + .priv_auto_alloc_size =sizeof (struct r8a66597 ), + .flags =DM_FLAG_ALLOC_PRIV_DMA , +};
Signature · 1 line
2.20.1
PATCH 6/8 usb: r8a66597: Convert to USB DM
Quoted 3 lines · Marek Vasut
Convert the R8A66597 USB driver to DM and add support for DT probing. Drop support for legacy non-DM and non-DT probing, since there are no platform using that.
I like the switch to DM :)
Chris
PATCH 7/8 usb: r8a66597: Add Kconfig entry
In reply to Marek VasutAdd missing Kconfig entry for the R8A66597 driver.
--- drivers/usb/host/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/host/Kconfig +9 -0
@@ -300,3 +300,12 @@ config USB_DWC2_BUFFER_SIZE because larger transactions could be split in smaller ones. endif # USB_DWC2 + +config USB_R8A66597_HCD + bool "Renesas R8A66597 USB Core support" + depends on OF_CONTROL + depends on DM_USB + select USB_HOST + ---help--- + This enables support for the on-chip Renesas R8A66597 USB 2.0 + controller, present in various RZ and SH SoCs.
Signature · 1 line
2.20.1
PATCH 8/8 usb: r8a66597: Checkpatch cleanup
In reply to Marek VasutFix remaining checkpatch complaints in the driver.
--- drivers/usb/host/r8a66597-hcd.c | 65 ++--- drivers/usb/host/r8a66597.h | 473 ++++++++++++++++---------------- 2 files changed, 269 insertions(+), 269 deletions(-)
drivers/usb/host/r8a66597-hcd.c +33 -32
@@ -58,17 +58,17 @@ static void get_hub_data(struct usb_device *dev, u16 *hub_devnum, u16 *hubport)/* check a device connected to root_hub */ if ((parent && parent->devnum ==1 ) || - (dev->devnum ==1 )) + dev->devnum ==1 )return ; *hub_devnum = (u8 )parent->devnum; *hubport = parent->portnr -1 ; -printf ("get_hub_data error.\n" ); +printf ("%s error.\n" , __func__); }static void set_devadd (struct r8a66597 *r8a66597,u8 r8a66597_address, -struct usb_device *dev,int port) +struct usb_device *dev,int port) {u16 val, usbspd, upphub, hubport;unsigned long devadd_reg =get_devadd_addr (r8a66597_address);
@@ -323,7 +323,7 @@ static int send_bulk_packet(struct r8a66597 *r8a66597, struct usb_device *dev,R8A66597_DPRINT ("%s\n" , __func__);r8a66597_mdfy (r8a66597,MBW |BULK_OUT_PIPENUM , -MBW |CURPIPE ,CFIFOSEL ); +MBW |CURPIPE ,CFIFOSEL );r8a66597_reg_wait (r8a66597,CFIFOSEL ,CURPIPE ,BULK_OUT_PIPENUM ); tmp =r8a66597_read (r8a66597,CFIFOCTR );if ((tmp &FRDY ) ==0 ) {
@@ -347,7 +347,7 @@ static int send_bulk_packet(struct r8a66597 *r8a66597, struct usb_device *dev, dev->act_len += size;r8a66597_mdfy (r8a66597,PID_BUF ,PID , -get_pipectr_addr (BULK_OUT_PIPENUM )); +get_pipectr_addr (BULK_OUT_PIPENUM ));while (!(r8a66597_read (r8a66597,BEMPSTS ) & (1 <<BULK_OUT_PIPENUM )))if (ctrlc ())
@@ -356,7 +356,7 @@ static int send_bulk_packet(struct r8a66597 *r8a66597, struct usb_device *dev,if (dev->act_len >= transfer_len)r8a66597_mdfy (r8a66597,PID_NAK ,PID , -get_pipectr_addr (BULK_OUT_PIPENUM )); +get_pipectr_addr (BULK_OUT_PIPENUM ));return 0 ; }
@@ -377,17 +377,17 @@ static int receive_bulk_packet(struct r8a66597 *r8a66597,/* prepare */ if (dev->act_len ==0 ) {r8a66597_mdfy (r8a66597,PID_NAK ,PID , -get_pipectr_addr (pipenum)); +get_pipectr_addr (pipenum));r8a66597_write (r8a66597, ~(1 << pipenum),BRDYSTS );r8a66597_write (r8a66597,TRCLR ,get_pipetre_addr (pipenum));r8a66597_write (r8a66597, - (transfer_len + maxpacket -1 ) / maxpacket, + (transfer_len + maxpacket -1 ) / maxpacket,get_pipetrn_addr (pipenum));r8a66597_bset (r8a66597,TRENB ,get_pipetre_addr (pipenum));r8a66597_mdfy (r8a66597,PID_BUF ,PID , -get_pipectr_addr (pipenum)); +get_pipectr_addr (pipenum)); }r8a66597_mdfy (r8a66597,MBW | pipenum,MBW |CURPIPE ,CFIFOSEL );
@@ -464,7 +464,7 @@ static int receive_control_packet(struct r8a66597 *r8a66597, }static int send_status_packet (struct r8a66597 *r8a66597, -unsigned long pipe) +unsigned long pipe) {r8a66597_bset (r8a66597,SQSET ,DCPCTR );r8a66597_mdfy (r8a66597,PID_NAK ,PID ,DCPCTR );
@@ -555,9 +555,7 @@ static int check_usb_device_connecting(struct r8a66597 *r8a66597)return -1 ;/* fail */ } -/*-------------------------------------------------------------------------* -* Virtual Root Hub -*-------------------------------------------------------------------------*/ +/* Virtual Root Hub */ #include <usbroothubdes.h>
@@ -639,34 +637,34 @@ static int r8a66597_submit_rh_msg(struct udevice *udev, struct usb_device *dev,switch ((wValue &0xff00 ) >>8 ) {case (0x01 ):/* device descriptor */ len = min_t(unsigned int, - leni, + leni, min_t(unsigned int, -sizeof (root_hub_dev_des), +sizeof (root_hub_dev_des), wLength));memcpy (buffer, root_hub_dev_des, len);break ;case (0x02 ):/* configuration descriptor */ len = min_t(unsigned int, - leni, + leni, min_t(unsigned int, -sizeof (root_hub_config_des), +sizeof (root_hub_config_des), wLength));memcpy (buffer, root_hub_config_des, len);break ;case (0x03 ):/* string descriptors */ if (wValue ==0x0300 ) { len = min_t(unsigned int, - leni, + leni, min_t(unsigned int, -sizeof (root_hub_str_index0), +sizeof (root_hub_str_index0), wLength));memcpy (buffer, root_hub_str_index0, len); }if (wValue ==0x0301 ) { len = min_t(unsigned int, - leni, + leni, min_t(unsigned int, -sizeof (root_hub_str_index1), +sizeof (root_hub_str_index1), wLength));memcpy (buffer, root_hub_str_index1, len); }
@@ -699,7 +697,8 @@ static int r8a66597_submit_rh_msg(struct udevice *udev, struct usb_device *dev, }else { data[0 ] +=2 ; data[8 ] = (temp &RH_B_DR ) >>8 ; - data[10 ] = data[9 ] =0xff ; + data[9 ] =0xff ; + data[10 ] =0xff ; } len = min_t(unsigned int, leni,
@@ -709,7 +708,7 @@ static int r8a66597_submit_rh_msg(struct udevice *udev, struct usb_device *dev, }case RH_GET_CONFIGURATION : - *(__u8 *) buffer =0x01 ; + *(__u8 *)buffer =0x01 ; len =1 ;break ;case RH_SET_CONFIGURATION :
@@ -729,9 +728,10 @@ static int r8a66597_submit_rh_msg(struct udevice *udev, struct usb_device *dev,return stat; } -static int r8a66597_submit_control_msg (struct udevice *udev,struct usb_device *dev, -unsigned long pipe,void *buffer,int length, -struct devrequest *setup) +static int r8a66597_submit_control_msg (struct udevice *udev, +struct usb_device *dev, +unsigned long pipe,void *buffer, +int length,struct devrequest *setup) {struct r8a66597 *r8a66597 =dev_get_priv (udev); u16 r8a66597_address = setup->request == USB_REQ_SET_ADDRESS ?
@@ -756,7 +756,7 @@ static int r8a66597_submit_control_msg(struct udevice *udev, struct usb_device * dev->act_len =0 ;if (usb_pipein (pipe))if (receive_control_packet (r8a66597, dev, buffer, - length) <0 ) + length) <0 )return -1 ;if (send_status_packet (r8a66597, pipe) <0 )
@@ -767,8 +767,9 @@ static int r8a66597_submit_control_msg(struct udevice *udev, struct usb_device *return 0 ; } -static int r8a66597_submit_bulk_msg (struct udevice *udev,struct usb_device *dev, -unsigned long pipe,void *buffer,int length) +static int r8a66597_submit_bulk_msg (struct udevice *udev, +struct usb_device *dev,unsigned long pipe, +void *buffer,int length) {struct r8a66597 *r8a66597 =dev_get_priv (udev);int ret =0 ;
@@ -790,10 +791,10 @@ static int r8a66597_submit_bulk_msg(struct udevice *udev, struct usb_device *devif (usb_pipein (pipe)) ret =receive_bulk_packet (r8a66597, dev, pipe, buffer, - length); + length);else ret =send_bulk_packet (r8a66597, dev, pipe, buffer, - length); + length); }if (ret ==0 )
@@ -826,7 +827,7 @@ static int r8a66597_usb_probe(struct udevice *dev)mdelay (100 );enable_controller (priv); -r8a66597_port_power (priv,0 ,1 ); +r8a66597_port_power (priv,0 ,1 );/* check usb device */ check_usb_device_connecting (priv);
drivers/usb/host/r8a66597.h +236 -237
574 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 1/8 usb: r8a66597: Remove CONFIG_SUPERH_ON_CHIP_R8A66597
In reply to Marek VasutQuoted 2 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Chris Brandt <[email protected]>
The series Looks good.
Thanks Marek!
Chris