Commit 0d365753 authored by David VomLehn's avatar David VomLehn Committed by Ralf Baechle

MIPS: PowerTV: Separate PowerTV USB support from non-USB code

Separate USB code into a file separate from asic/asic_devices.

Separating the USB code from everything else in asic/asic_devices.c goes
a long way toward reducing the use of that file as a dumping ground for
everything that didn't seem to fit anywhere else.
Signed-off-by: default avatarDavid VomLehn <dvomlehn@cisco.com>
To: linux-mips@linux-mips.org
Cc: greg@kroah.com
Cc: linux-usb@vger.kernel.org
Patchwork: http://patchwork.linux-mips.org/patch/1522/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 5089ca9d
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#define _ASM_MACH_POWERTV_ASIC_H #define _ASM_MACH_POWERTV_ASIC_H
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/platform_device.h>
#include <asm/mach-powertv/asic_regs.h> #include <asm/mach-powertv/asic_regs.h>
#define DVR_CAPABLE (1<<0) #define DVR_CAPABLE (1<<0)
...@@ -71,16 +72,24 @@ extern int platform_supports_ffs(void); ...@@ -71,16 +72,24 @@ extern int platform_supports_ffs(void);
extern int platform_supports_pcie(void); extern int platform_supports_pcie(void);
extern int platform_supports_display(void); extern int platform_supports_display(void);
extern void configure_platform(void); extern void configure_platform(void);
extern void platform_configure_usb_ehci(void);
extern void platform_unconfigure_usb_ehci(void);
extern void platform_configure_usb_ohci(void);
extern void platform_unconfigure_usb_ohci(void);
/* Platform Resources */ /* Platform Resources */
#define ASIC_RESOURCE_GET_EXISTS 1 #define ASIC_RESOURCE_GET_EXISTS 1
extern struct resource *asic_resource_get(const char *name); extern struct resource *asic_resource_get(const char *name);
extern void platform_release_memory(void *baddr, int size); extern void platform_release_memory(void *baddr, int size);
/* USB configuration */
struct usb_hcd; /* Forward reference */
extern void platform_configure_usb_ehci(void);
extern void platform_unconfigure_usb_ehci(void);
extern void platform_configure_usb_ohci(void);
extern void platform_unconfigure_usb_ohci(void);
/* Resource for ASIC registers */
extern struct resource asic_resource;
extern int platform_usb_devices_init(struct platform_device **echi_dev,
struct platform_device **ohci_dev);
/* Reboot Cause */ /* Reboot Cause */
extern void set_reboot_cause(char code, unsigned int data, unsigned int data2); extern void set_reboot_cause(char code, unsigned int data, unsigned int data2);
extern void set_locked_reboot_cause(char code, unsigned int data, extern void set_locked_reboot_cause(char code, unsigned int data,
......
...@@ -101,6 +101,7 @@ static inline void register_map_virtualize(struct register_map *map) ...@@ -101,6 +101,7 @@ static inline void register_map_virtualize(struct register_map *map)
} }
extern struct register_map _asic_register_map; extern struct register_map _asic_register_map;
extern unsigned long asic_phy_base;
/* /*
* Macros to interface to registers through their ioremapped address * Macros to interface to registers through their ioremapped address
......
...@@ -26,4 +26,6 @@ ...@@ -26,4 +26,6 @@
obj-y += init.o ioremap.o memory.o powertv_setup.o reset.o time.o \ obj-y += init.o ioremap.o memory.o powertv_setup.o reset.o time.o \
asic/ pci/ asic/ pci/
obj-$(CONFIG_USB) += powertv-usb.o
EXTRA_CFLAGS += -Wall EXTRA_CFLAGS += -Wall
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/gfp.h>
#include <asm/page.h> #include <asm/page.h>
#include <linux/swap.h> #include <linux/swap.h>
#include <linux/highmem.h> #include <linux/highmem.h>
...@@ -68,7 +67,6 @@ unsigned long asic_phy_base; ...@@ -68,7 +67,6 @@ unsigned long asic_phy_base;
unsigned long asic_base; unsigned long asic_base;
EXPORT_SYMBOL(asic_base); /* Exported for testing */ EXPORT_SYMBOL(asic_base); /* Exported for testing */
struct resource *gp_resources; struct resource *gp_resources;
static bool usb_configured;
/* /*
* Don't recommend to use it directly, it is usually used by kernel internally. * Don't recommend to use it directly, it is usually used by kernel internally.
...@@ -90,102 +88,20 @@ struct resource asic_resource = { ...@@ -90,102 +88,20 @@ struct resource asic_resource = {
.flags = IORESOURCE_MEM, .flags = IORESOURCE_MEM,
}; };
/*
*
* USB Host Resource Definition
*
*/
static struct resource ehci_resources[] = {
{
.parent = &asic_resource,
.start = 0,
.end = 0xff,
.flags = IORESOURCE_MEM,
},
{
.start = irq_usbehci,
.end = irq_usbehci,
.flags = IORESOURCE_IRQ,
},
};
static u64 ehci_dmamask = DMA_BIT_MASK(32);
static struct platform_device ehci_device = {
.name = "powertv-ehci",
.id = 0,
.num_resources = 2,
.resource = ehci_resources,
.dev = {
.dma_mask = &ehci_dmamask,
.coherent_dma_mask = DMA_BIT_MASK(32),
},
};
static struct resource ohci_resources[] = {
{
.parent = &asic_resource,
.start = 0,
.end = 0xff,
.flags = IORESOURCE_MEM,
},
{
.start = irq_usbohci,
.end = irq_usbohci,
.flags = IORESOURCE_IRQ,
},
};
static u64 ohci_dmamask = DMA_BIT_MASK(32);
static struct platform_device ohci_device = {
.name = "powertv-ohci",
.id = 0,
.num_resources = 2,
.resource = ohci_resources,
.dev = {
.dma_mask = &ohci_dmamask,
.coherent_dma_mask = DMA_BIT_MASK(32),
},
};
static struct platform_device *platform_devices[] = {
&ehci_device,
&ohci_device,
};
/*
*
* Platform Configuration and Device Initialization
*
*/
static void __init fs_update(int pe, int md, int sdiv, int disable_div_by_3)
{
int en_prg, byp, pwr, nsb, val;
int sout;
sout = 1;
en_prg = 1;
byp = 0;
nsb = 1;
pwr = 1;
val = ((sdiv << 29) | (md << 24) | (pe<<8) | (sout<<3) | (byp<<2) |
(nsb<<1) | (disable_div_by_3<<5));
asic_write(val, fs432x4b4_usb_ctl);
asic_write(val | (en_prg<<4), fs432x4b4_usb_ctl);
asic_write(val | (en_prg<<4) | pwr, fs432x4b4_usb_ctl);
}
/* /*
* Allow override of bootloader-specified model * Allow override of bootloader-specified model
* Returns zero on success, a negative errno value on failure. This parameter
* allows overriding of the bootloader-specified model.
*/ */
static char __initdata cmdline[COMMAND_LINE_SIZE]; static char __initdata cmdline[COMMAND_LINE_SIZE];
#define FORCEFAMILY_PARAM "forcefamily" #define FORCEFAMILY_PARAM "forcefamily"
/*
* check_forcefamily - check for, and parse, forcefamily command line parameter
* @forced_family: Pointer to two-character array in which to store the
* value of the forcedfamily parameter, if any.
*/
static __init int check_forcefamily(unsigned char forced_family[2]) static __init int check_forcefamily(unsigned char forced_family[2])
{ {
const char *p; const char *p;
...@@ -225,14 +141,10 @@ static __init int check_forcefamily(unsigned char forced_family[2]) ...@@ -225,14 +141,10 @@ static __init int check_forcefamily(unsigned char forced_family[2])
*/ */
static __init noinline void platform_set_family(void) static __init noinline void platform_set_family(void)
{ {
#define BOOTLDRFAMILY(byte1, byte0) (((byte1) << 8) | (byte0))
unsigned char forced_family[2]; unsigned char forced_family[2];
unsigned short bootldr_family; unsigned short bootldr_family;
check_forcefamily(forced_family); if (check_forcefamily(forced_family) == 0)
if (forced_family[0] != '\0' && forced_family[1] != '\0')
bootldr_family = BOOTLDRFAMILY(forced_family[0], bootldr_family = BOOTLDRFAMILY(forced_family[0],
forced_family[1]); forced_family[1]);
else { else {
...@@ -297,25 +209,10 @@ unsigned int platform_get_family(void) ...@@ -297,25 +209,10 @@ unsigned int platform_get_family(void)
} }
EXPORT_SYMBOL(platform_get_family); EXPORT_SYMBOL(platform_get_family);
/*
* \brief usb_eye_configure() for optimizing the USB eye on Calliope.
*
* \param unsigned int value saved to the register.
*
* \return none
*
*/
static void __init usb_eye_configure(unsigned int value)
{
asic_write(asic_read(crt_spare) | value, crt_spare);
}
/* /*
* platform_get_asic - determine the ASIC type. * platform_get_asic - determine the ASIC type.
* *
* \param none * Returns the ASIC type, or ASIC_UNKNOWN if unknown
*
* \return ASIC type; ASIC_UNKNOWN if none
* *
*/ */
enum asic_type platform_get_asic(void) enum asic_type platform_get_asic(void)
...@@ -325,93 +222,10 @@ enum asic_type platform_get_asic(void) ...@@ -325,93 +222,10 @@ enum asic_type platform_get_asic(void)
EXPORT_SYMBOL(platform_get_asic); EXPORT_SYMBOL(platform_get_asic);
/* /*
* platform_configure_usb - usb configuration based on platform type. * set_register_map - set ASIC register configuration
* @bcm1_usb2_ctl: value for the BCM1_USB2_CTL register, which is * @phys_base: Physical address of the base of the ASIC registers
* quirky * @map: Description of key ASIC registers
*/
static void __init platform_configure_usb(void)
{
u32 bcm1_usb2_ctl;
if (usb_configured)
return;
switch (asic) {
case ASIC_ZEUS:
case ASIC_CRONUS:
case ASIC_CRONUSLITE:
fs_update(0x0000, 0x11, 0x02, 0);
bcm1_usb2_ctl = 0x803;
break;
case ASIC_CALLIOPE:
fs_update(0x0000, 0x11, 0x02, 1);
switch (platform_family) {
case FAMILY_1500VZE:
break;
case FAMILY_1500VZF:
usb_eye_configure(0x003c0000);
break;
default:
usb_eye_configure(0x00300000);
break;
}
bcm1_usb2_ctl = 0x803;
break;
default:
pr_err("Unknown ASIC type: %d\n", asic);
break;
}
/* turn on USB power */
asic_write(0, usb2_strap);
/* Enable all OHCI interrupts */
asic_write(bcm1_usb2_ctl, usb2_control);
/* USB2_STBUS_OBC store32/load32 */
asic_write(3, usb2_stbus_obc);
/* USB2_STBUS_MESS_SIZE 2 packets */
asic_write(1, usb2_stbus_mess_size);
/* USB2_STBUS_CHUNK_SIZE 2 packets */
asic_write(1, usb2_stbus_chunk_size);
usb_configured = true;
}
/*
* Set up the USB EHCI interface
*/
void platform_configure_usb_ehci()
{
platform_configure_usb();
}
/*
* Set up the USB OHCI interface
*/
void platform_configure_usb_ohci()
{
platform_configure_usb();
}
/*
* Shut the USB EHCI interface down--currently a NOP
*/ */
void platform_unconfigure_usb_ehci()
{
}
/*
* Shut the USB OHCI interface down--currently a NOP
*/
void platform_unconfigure_usb_ohci()
{
}
static void __init set_register_map(unsigned long phys_base, static void __init set_register_map(unsigned long phys_base,
const struct register_map *map) const struct register_map *map)
{ {
...@@ -560,34 +374,8 @@ void __init configure_platform(void) ...@@ -560,34 +374,8 @@ void __init configure_platform(void)
} }
} }
/**
* platform_devices_init - sets up USB device resourse.
*/
static int __init platform_devices_init(void)
{
pr_notice("%s: ----- Initializing USB resources -----\n", __func__);
asic_resource.start = asic_phy_base;
asic_resource.end += asic_resource.start;
ehci_resources[0].start = asic_reg_phys_addr(ehci_hcapbase);
ehci_resources[0].end += ehci_resources[0].start;
ohci_resources[0].start = asic_reg_phys_addr(ohci_hc_revision);
ohci_resources[0].end += ohci_resources[0].start;
set_io_port_base(0);
platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
return 0;
}
arch_initcall(platform_devices_init);
/* /*
* * RESOURCE ALLOCATION
* BOOTMEM ALLOCATION
* *
*/ */
/* /*
......
This diff is collapsed.
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