Commit 719a72b7 authored by Magnus Damm's avatar Magnus Damm Committed by Paul Mundt

usb: r8a66597-hcd platform data on_chip support

Convert the r8a66597-hcd driver to use the on_chip flag
from platform data to enable on chip behaviour instead
of relying on CONFIG_SUPERH_ON_CHIP_R8A66597 ugliness.

This makes the code cleaner and also allows us to support
both external and internal r8a66597 with the same kernel.

It also makes the Kconfig part more future proof since
we with this patch can add support for new processors
with on-chip r8a66597 without modifying the Kconfig.
Signed-off-by: default avatarMagnus Damm <damm@igel.co.jp>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent ae1cef6e
...@@ -304,6 +304,7 @@ static struct platform_device sh_eth_device = { ...@@ -304,6 +304,7 @@ static struct platform_device sh_eth_device = {
}; };
static struct r8a66597_platdata sh7724_usb0_host_data = { static struct r8a66597_platdata sh7724_usb0_host_data = {
.on_chip = 1,
}; };
static struct resource sh7724_usb0_host_resources[] = { static struct resource sh7724_usb0_host_resources[] = {
......
...@@ -40,7 +40,7 @@ static struct platform_device iic_device = { ...@@ -40,7 +40,7 @@ static struct platform_device iic_device = {
}; };
static struct r8a66597_platdata r8a66597_data = { static struct r8a66597_platdata r8a66597_data = {
/* This set zero to all members */ .on_chip = 1,
}; };
static struct resource usb_host_resources[] = { static struct resource usb_host_resources[] = {
......
...@@ -398,7 +398,7 @@ static struct platform_device rtc_device = { ...@@ -398,7 +398,7 @@ static struct platform_device rtc_device = {
}; };
static struct r8a66597_platdata r8a66597_data = { static struct r8a66597_platdata r8a66597_data = {
/* This set zero to all members */ .on_chip = 1,
}; };
static struct resource sh7723_usb_host_resources[] = { static struct resource sh7723_usb_host_resources[] = {
......
...@@ -336,13 +336,6 @@ config USB_R8A66597_HCD ...@@ -336,13 +336,6 @@ config USB_R8A66597_HCD
To compile this driver as a module, choose M here: the To compile this driver as a module, choose M here: the
module will be called r8a66597-hcd. module will be called r8a66597-hcd.
config SUPERH_ON_CHIP_R8A66597
boolean "Enable SuperH on-chip R8A66597 USB"
depends on USB_R8A66597_HCD && (CPU_SUBTYPE_SH7366 || CPU_SUBTYPE_SH7723 || CPU_SUBTYPE_SH7724)
help
This driver enables support for the on-chip R8A66597 in the
SH7366, SH7723 and SH7724 processors.
config USB_WHCI_HCD config USB_WHCI_HCD
tristate "Wireless USB Host Controller Interface (WHCI) driver (EXPERIMENTAL)" tristate "Wireless USB Host Controller Interface (WHCI) driver (EXPERIMENTAL)"
depends on EXPERIMENTAL depends on EXPERIMENTAL
......
This diff is collapsed.
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#ifndef __R8A66597_H__ #ifndef __R8A66597_H__
#define __R8A66597_H__ #define __R8A66597_H__
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) #ifdef CONFIG_HAVE_CLK
#include <linux/clk.h> #include <linux/clk.h>
#endif #endif
...@@ -193,13 +193,9 @@ ...@@ -193,13 +193,9 @@
#define REW 0x4000 /* b14: Buffer rewind */ #define REW 0x4000 /* b14: Buffer rewind */
#define DCLRM 0x2000 /* b13: DMA buffer clear mode */ #define DCLRM 0x2000 /* b13: DMA buffer clear mode */
#define DREQE 0x1000 /* b12: DREQ output enable */ #define DREQE 0x1000 /* b12: DREQ output enable */
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
#define MBW 0x0800
#else
#define MBW 0x0400 /* b10: Maximum bit width for FIFO access */
#endif
#define MBW_8 0x0000 /* 8bit */ #define MBW_8 0x0000 /* 8bit */
#define MBW_16 0x0400 /* 16bit */ #define MBW_16 0x0400 /* 16bit */
#define MBW_32 0x0800 /* 32bit */
#define BIGEND 0x0100 /* b8: Big endian mode */ #define BIGEND 0x0100 /* b8: Big endian mode */
#define BYTE_LITTLE 0x0000 /* little dendian */ #define BYTE_LITTLE 0x0000 /* little dendian */
#define BYTE_BIG 0x0100 /* big endifan */ #define BYTE_BIG 0x0100 /* big endifan */
...@@ -405,11 +401,7 @@ ...@@ -405,11 +401,7 @@
#define R8A66597_MAX_NUM_PIPE 10 #define R8A66597_MAX_NUM_PIPE 10
#define R8A66597_BUF_BSIZE 8 #define R8A66597_BUF_BSIZE 8
#define R8A66597_MAX_DEVICE 10 #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 #define R8A66597_MAX_ROOT_HUB 2
#endif
#define R8A66597_MAX_SAMPLING 5 #define R8A66597_MAX_SAMPLING 5
#define R8A66597_RH_POLL_TIME 10 #define R8A66597_RH_POLL_TIME 10
#define R8A66597_MAX_DMA_CHANNEL 2 #define R8A66597_MAX_DMA_CHANNEL 2
...@@ -487,7 +479,7 @@ struct r8a66597_root_hub { ...@@ -487,7 +479,7 @@ struct r8a66597_root_hub {
struct r8a66597 { struct r8a66597 {
spinlock_t lock; spinlock_t lock;
unsigned long reg; unsigned long reg;
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) #ifdef CONFIG_HAVE_CLK
struct clk *clk; struct clk *clk;
#endif #endif
struct r8a66597_platdata *pdata; struct r8a66597_platdata *pdata;
...@@ -504,6 +496,7 @@ struct r8a66597 { ...@@ -504,6 +496,7 @@ struct r8a66597 {
unsigned short interval_map; unsigned short interval_map;
unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE]; unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE];
unsigned char dma_map; unsigned char dma_map;
unsigned int max_root_hub;
struct list_head child_device; struct list_head child_device;
unsigned long child_connect_map[4]; unsigned long child_connect_map[4];
...@@ -550,21 +543,22 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597, ...@@ -550,21 +543,22 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597,
unsigned long offset, u16 *buf, unsigned long offset, u16 *buf,
int len) int len)
{ {
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
unsigned long fifoaddr = r8a66597->reg + offset; unsigned long fifoaddr = r8a66597->reg + offset;
unsigned long count; unsigned long count;
count = len / 4; if (r8a66597->pdata->on_chip) {
insl(fifoaddr, buf, count); count = len / 4;
insl(fifoaddr, buf, count);
if (len & 0x00000003) { if (len & 0x00000003) {
unsigned long tmp = inl(fifoaddr); unsigned long tmp = inl(fifoaddr);
memcpy((unsigned char *)buf + count * 4, &tmp, len & 0x03); memcpy((unsigned char *)buf + count * 4, &tmp,
len & 0x03);
}
} else {
len = (len + 1) / 2;
insw(fifoaddr, buf, len);
} }
#else
len = (len + 1) / 2;
insw(r8a66597->reg + offset, buf, len);
#endif
} }
static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val,
...@@ -578,33 +572,33 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, ...@@ -578,33 +572,33 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
int len) int len)
{ {
unsigned long fifoaddr = r8a66597->reg + offset; unsigned long fifoaddr = r8a66597->reg + offset;
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
unsigned long count; unsigned long count;
unsigned char *pb; unsigned char *pb;
int i; int i;
count = len / 4; if (r8a66597->pdata->on_chip) {
outsl(fifoaddr, buf, count); count = len / 4;
outsl(fifoaddr, buf, count);
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);
else
outb(pb[i], fifoaddr + 3 - i);
}
}
} else {
int odd = len & 0x0001;
if (len & 0x00000003) { len = len / 2;
pb = (unsigned char *)buf + count * 4; outsw(fifoaddr, buf, len);
for (i = 0; i < (len & 0x00000003); i++) { if (unlikely(odd)) {
if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND) buf = &buf[len];
outb(pb[i], fifoaddr + i); outb((unsigned char)*buf, fifoaddr);
else
outb(pb[i], fifoaddr + 3 - i);
} }
} }
#else
int odd = len & 0x0001;
len = len / 2;
outsw(fifoaddr, buf, len);
if (unlikely(odd)) {
buf = &buf[len];
outb((unsigned char)*buf, fifoaddr);
}
#endif
} }
static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, static inline void r8a66597_mdfy(struct r8a66597 *r8a66597,
......
...@@ -31,6 +31,9 @@ struct r8a66597_platdata { ...@@ -31,6 +31,9 @@ struct r8a66597_platdata {
/* This ops can controll port power instead of DVSTCTR register. */ /* This ops can controll port power instead of DVSTCTR register. */
void (*port_power)(int port, int power); void (*port_power)(int port, int power);
/* set one = on chip controller, set zero = external controller */
unsigned on_chip:1;
/* (external controller only) set R8A66597_PLATDATA_XTAL_nnMHZ */ /* (external controller only) set R8A66597_PLATDATA_XTAL_nnMHZ */
unsigned xtal:2; unsigned xtal:2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment