aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/powertv/asic
diff options
context:
space:
mode:
authorDavid VomLehn <dvomlehn@cisco.com>2010-08-02 21:40:58 -0400
committerRalf Baechle <ralf@linux-mips.org>2010-08-05 08:26:34 -0400
commit0d365753d0b7c26043fdfa97790411606fb40112 (patch)
tree8ad3a06bf6c5299151a611d55c7e5b2a5d63fec6 /arch/mips/powertv/asic
parent5089ca9d31b0250f42ccd0e0a41b3547f22a20a0 (diff)
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: David 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: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/powertv/asic')
-rw-r--r--arch/mips/powertv/asic/asic_devices.c238
1 files changed, 13 insertions, 225 deletions
diff --git a/arch/mips/powertv/asic/asic_devices.c b/arch/mips/powertv/asic/asic_devices.c
index 095a887df39c..e56fa61b3991 100644
--- a/arch/mips/powertv/asic/asic_devices.c
+++ b/arch/mips/powertv/asic/asic_devices.c
@@ -33,7 +33,6 @@
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/gfp.h>
37#include <asm/page.h> 36#include <asm/page.h>
38#include <linux/swap.h> 37#include <linux/swap.h>
39#include <linux/highmem.h> 38#include <linux/highmem.h>
@@ -68,7 +67,6 @@ unsigned long asic_phy_base;
68unsigned long asic_base; 67unsigned long asic_base;
69EXPORT_SYMBOL(asic_base); /* Exported for testing */ 68EXPORT_SYMBOL(asic_base); /* Exported for testing */
70struct resource *gp_resources; 69struct resource *gp_resources;
71static bool usb_configured;
72 70
73/* 71/*
74 * Don't recommend to use it directly, it is usually used by kernel internally. 72 * Don't recommend to use it directly, it is usually used by kernel internally.
@@ -91,101 +89,19 @@ struct resource asic_resource = {
91}; 89};
92 90
93/* 91/*
94 *
95 * USB Host Resource Definition
96 *
97 */
98
99static struct resource ehci_resources[] = {
100 {
101 .parent = &asic_resource,
102 .start = 0,
103 .end = 0xff,
104 .flags = IORESOURCE_MEM,
105 },
106 {
107 .start = irq_usbehci,
108 .end = irq_usbehci,
109 .flags = IORESOURCE_IRQ,
110 },
111};
112
113static u64 ehci_dmamask = DMA_BIT_MASK(32);
114
115static struct platform_device ehci_device = {
116 .name = "powertv-ehci",
117 .id = 0,
118 .num_resources = 2,
119 .resource = ehci_resources,
120 .dev = {
121 .dma_mask = &ehci_dmamask,
122 .coherent_dma_mask = DMA_BIT_MASK(32),
123 },
124};
125
126static struct resource ohci_resources[] = {
127 {
128 .parent = &asic_resource,
129 .start = 0,
130 .end = 0xff,
131 .flags = IORESOURCE_MEM,
132 },
133 {
134 .start = irq_usbohci,
135 .end = irq_usbohci,
136 .flags = IORESOURCE_IRQ,
137 },
138};
139
140static u64 ohci_dmamask = DMA_BIT_MASK(32);
141
142static struct platform_device ohci_device = {
143 .name = "powertv-ohci",
144 .id = 0,
145 .num_resources = 2,
146 .resource = ohci_resources,
147 .dev = {
148 .dma_mask = &ohci_dmamask,
149 .coherent_dma_mask = DMA_BIT_MASK(32),
150 },
151};
152
153static struct platform_device *platform_devices[] = {
154 &ehci_device,
155 &ohci_device,
156};
157
158/*
159 *
160 * Platform Configuration and Device Initialization
161 *
162 */
163static void __init fs_update(int pe, int md, int sdiv, int disable_div_by_3)
164{
165 int en_prg, byp, pwr, nsb, val;
166 int sout;
167
168 sout = 1;
169 en_prg = 1;
170 byp = 0;
171 nsb = 1;
172 pwr = 1;
173
174 val = ((sdiv << 29) | (md << 24) | (pe<<8) | (sout<<3) | (byp<<2) |
175 (nsb<<1) | (disable_div_by_3<<5));
176
177 asic_write(val, fs432x4b4_usb_ctl);
178 asic_write(val | (en_prg<<4), fs432x4b4_usb_ctl);
179 asic_write(val | (en_prg<<4) | pwr, fs432x4b4_usb_ctl);
180}
181
182/*
183 * Allow override of bootloader-specified model 92 * Allow override of bootloader-specified model
93 * Returns zero on success, a negative errno value on failure. This parameter
94 * allows overriding of the bootloader-specified model.
184 */ 95 */
185static char __initdata cmdline[COMMAND_LINE_SIZE]; 96static char __initdata cmdline[COMMAND_LINE_SIZE];
186 97
187#define FORCEFAMILY_PARAM "forcefamily" 98#define FORCEFAMILY_PARAM "forcefamily"
188 99
100/*
101 * check_forcefamily - check for, and parse, forcefamily command line parameter
102 * @forced_family: Pointer to two-character array in which to store the
103 * value of the forcedfamily parameter, if any.
104 */
189static __init int check_forcefamily(unsigned char forced_family[2]) 105static __init int check_forcefamily(unsigned char forced_family[2])
190{ 106{
191 const char *p; 107 const char *p;
@@ -225,14 +141,10 @@ static __init int check_forcefamily(unsigned char forced_family[2])
225 */ 141 */
226static __init noinline void platform_set_family(void) 142static __init noinline void platform_set_family(void)
227{ 143{
228#define BOOTLDRFAMILY(byte1, byte0) (((byte1) << 8) | (byte0))
229
230 unsigned char forced_family[2]; 144 unsigned char forced_family[2];
231 unsigned short bootldr_family; 145 unsigned short bootldr_family;
232 146
233 check_forcefamily(forced_family); 147 if (check_forcefamily(forced_family) == 0)
234
235 if (forced_family[0] != '\0' && forced_family[1] != '\0')
236 bootldr_family = BOOTLDRFAMILY(forced_family[0], 148 bootldr_family = BOOTLDRFAMILY(forced_family[0],
237 forced_family[1]); 149 forced_family[1]);
238 else { 150 else {
@@ -298,24 +210,9 @@ unsigned int platform_get_family(void)
298EXPORT_SYMBOL(platform_get_family); 210EXPORT_SYMBOL(platform_get_family);
299 211
300/* 212/*
301 * \brief usb_eye_configure() for optimizing the USB eye on Calliope.
302 *
303 * \param unsigned int value saved to the register.
304 *
305 * \return none
306 *
307 */
308static void __init usb_eye_configure(unsigned int value)
309{
310 asic_write(asic_read(crt_spare) | value, crt_spare);
311}
312
313/*
314 * platform_get_asic - determine the ASIC type. 213 * platform_get_asic - determine the ASIC type.
315 * 214 *
316 * \param none 215 * Returns the ASIC type, or ASIC_UNKNOWN if unknown
317 *
318 * \return ASIC type; ASIC_UNKNOWN if none
319 * 216 *
320 */ 217 */
321enum asic_type platform_get_asic(void) 218enum asic_type platform_get_asic(void)
@@ -325,93 +222,10 @@ enum asic_type platform_get_asic(void)
325EXPORT_SYMBOL(platform_get_asic); 222EXPORT_SYMBOL(platform_get_asic);
326 223
327/* 224/*
328 * platform_configure_usb - usb configuration based on platform type. 225 * set_register_map - set ASIC register configuration
329 * @bcm1_usb2_ctl: value for the BCM1_USB2_CTL register, which is 226 * @phys_base: Physical address of the base of the ASIC registers
330 * quirky 227 * @map: Description of key ASIC registers
331 */
332static void __init platform_configure_usb(void)
333{
334 u32 bcm1_usb2_ctl;
335
336 if (usb_configured)
337 return;
338
339 switch (asic) {
340 case ASIC_ZEUS:
341 case ASIC_CRONUS:
342 case ASIC_CRONUSLITE:
343 fs_update(0x0000, 0x11, 0x02, 0);
344 bcm1_usb2_ctl = 0x803;
345 break;
346
347 case ASIC_CALLIOPE:
348 fs_update(0x0000, 0x11, 0x02, 1);
349
350 switch (platform_family) {
351 case FAMILY_1500VZE:
352 break;
353
354 case FAMILY_1500VZF:
355 usb_eye_configure(0x003c0000);
356 break;
357
358 default:
359 usb_eye_configure(0x00300000);
360 break;
361 }
362
363 bcm1_usb2_ctl = 0x803;
364 break;
365
366 default:
367 pr_err("Unknown ASIC type: %d\n", asic);
368 break;
369 }
370
371 /* turn on USB power */
372 asic_write(0, usb2_strap);
373 /* Enable all OHCI interrupts */
374 asic_write(bcm1_usb2_ctl, usb2_control);
375 /* USB2_STBUS_OBC store32/load32 */
376 asic_write(3, usb2_stbus_obc);
377 /* USB2_STBUS_MESS_SIZE 2 packets */
378 asic_write(1, usb2_stbus_mess_size);
379 /* USB2_STBUS_CHUNK_SIZE 2 packets */
380 asic_write(1, usb2_stbus_chunk_size);
381
382 usb_configured = true;
383}
384
385/*
386 * Set up the USB EHCI interface
387 */
388void platform_configure_usb_ehci()
389{
390 platform_configure_usb();
391}
392
393/*
394 * Set up the USB OHCI interface
395 */
396void platform_configure_usb_ohci()
397{
398 platform_configure_usb();
399}
400
401/*
402 * Shut the USB EHCI interface down--currently a NOP
403 */ 228 */
404void platform_unconfigure_usb_ehci()
405{
406}
407
408/*
409 * Shut the USB OHCI interface down--currently a NOP
410 */
411void platform_unconfigure_usb_ohci()
412{
413}
414
415static void __init set_register_map(unsigned long phys_base, 229static void __init set_register_map(unsigned long phys_base,
416 const struct register_map *map) 230 const struct register_map *map)
417{ 231{
@@ -560,34 +374,8 @@ void __init configure_platform(void)
560 } 374 }
561} 375}
562 376
563/**
564 * platform_devices_init - sets up USB device resourse.
565 */
566static int __init platform_devices_init(void)
567{
568 pr_notice("%s: ----- Initializing USB resources -----\n", __func__);
569
570 asic_resource.start = asic_phy_base;
571 asic_resource.end += asic_resource.start;
572
573 ehci_resources[0].start = asic_reg_phys_addr(ehci_hcapbase);
574 ehci_resources[0].end += ehci_resources[0].start;
575
576 ohci_resources[0].start = asic_reg_phys_addr(ohci_hc_revision);
577 ohci_resources[0].end += ohci_resources[0].start;
578
579 set_io_port_base(0);
580
581 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
582
583 return 0;
584}
585
586arch_initcall(platform_devices_init);
587
588/* 377/*
589 * 378 * RESOURCE ALLOCATION
590 * BOOTMEM ALLOCATION
591 * 379 *
592 */ 380 */
593/* 381/*