diff options
Diffstat (limited to 'drivers/ssb/driver_chipcommon.c')
-rw-r--r-- | drivers/ssb/driver_chipcommon.c | 65 |
1 files changed, 54 insertions, 11 deletions
diff --git a/drivers/ssb/driver_chipcommon.c b/drivers/ssb/driver_chipcommon.c index 6fbf1c53b6f2..e586321a473a 100644 --- a/drivers/ssb/driver_chipcommon.c +++ b/drivers/ssb/driver_chipcommon.c | |||
@@ -39,12 +39,14 @@ static inline void chipco_write32(struct ssb_chipcommon *cc, | |||
39 | ssb_write32(cc->dev, offset, value); | 39 | ssb_write32(cc->dev, offset, value); |
40 | } | 40 | } |
41 | 41 | ||
42 | static inline void chipco_write32_masked(struct ssb_chipcommon *cc, u16 offset, | 42 | static inline u32 chipco_write32_masked(struct ssb_chipcommon *cc, u16 offset, |
43 | u32 mask, u32 value) | 43 | u32 mask, u32 value) |
44 | { | 44 | { |
45 | value &= mask; | 45 | value &= mask; |
46 | value |= chipco_read32(cc, offset) & ~mask; | 46 | value |= chipco_read32(cc, offset) & ~mask; |
47 | chipco_write32(cc, offset, value); | 47 | chipco_write32(cc, offset, value); |
48 | |||
49 | return value; | ||
48 | } | 50 | } |
49 | 51 | ||
50 | void ssb_chipco_set_clockmode(struct ssb_chipcommon *cc, | 52 | void ssb_chipco_set_clockmode(struct ssb_chipcommon *cc, |
@@ -356,14 +358,29 @@ u32 ssb_chipco_gpio_in(struct ssb_chipcommon *cc, u32 mask) | |||
356 | return chipco_read32(cc, SSB_CHIPCO_GPIOIN) & mask; | 358 | return chipco_read32(cc, SSB_CHIPCO_GPIOIN) & mask; |
357 | } | 359 | } |
358 | 360 | ||
359 | void ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value) | 361 | u32 ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value) |
362 | { | ||
363 | return chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUT, mask, value); | ||
364 | } | ||
365 | |||
366 | u32 ssb_chipco_gpio_outen(struct ssb_chipcommon *cc, u32 mask, u32 value) | ||
367 | { | ||
368 | return chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUTEN, mask, value); | ||
369 | } | ||
370 | |||
371 | u32 ssb_chipco_gpio_control(struct ssb_chipcommon *cc, u32 mask, u32 value) | ||
372 | { | ||
373 | return chipco_write32_masked(cc, SSB_CHIPCO_GPIOCTL, mask, value); | ||
374 | } | ||
375 | |||
376 | u32 ssb_chipco_gpio_intmask(struct ssb_chipcommon *cc, u32 mask, u32 value) | ||
360 | { | 377 | { |
361 | chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUT, mask, value); | 378 | return chipco_write32_masked(cc, SSB_CHIPCO_GPIOIRQ, mask, value); |
362 | } | 379 | } |
363 | 380 | ||
364 | void ssb_chipco_gpio_outen(struct ssb_chipcommon *cc, u32 mask, u32 value) | 381 | u32 ssb_chipco_gpio_polarity(struct ssb_chipcommon *cc, u32 mask, u32 value) |
365 | { | 382 | { |
366 | chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUTEN, mask, value); | 383 | return chipco_write32_masked(cc, SSB_CHIPCO_GPIOPOL, mask, value); |
367 | } | 384 | } |
368 | 385 | ||
369 | #ifdef CONFIG_SSB_SERIAL | 386 | #ifdef CONFIG_SSB_SERIAL |
@@ -376,6 +393,7 @@ int ssb_chipco_serial_init(struct ssb_chipcommon *cc, | |||
376 | unsigned int irq; | 393 | unsigned int irq; |
377 | u32 baud_base, div; | 394 | u32 baud_base, div; |
378 | u32 i, n; | 395 | u32 i, n; |
396 | unsigned int ccrev = cc->dev->id.revision; | ||
379 | 397 | ||
380 | plltype = (cc->capabilities & SSB_CHIPCO_CAP_PLLT); | 398 | plltype = (cc->capabilities & SSB_CHIPCO_CAP_PLLT); |
381 | irq = ssb_mips_irq(cc->dev); | 399 | irq = ssb_mips_irq(cc->dev); |
@@ -387,14 +405,39 @@ int ssb_chipco_serial_init(struct ssb_chipcommon *cc, | |||
387 | chipco_read32(cc, SSB_CHIPCO_CLOCK_M2)); | 405 | chipco_read32(cc, SSB_CHIPCO_CLOCK_M2)); |
388 | div = 1; | 406 | div = 1; |
389 | } else { | 407 | } else { |
390 | if (cc->dev->id.revision >= 11) { | 408 | if (ccrev == 20) { |
409 | /* BCM5354 uses constant 25MHz clock */ | ||
410 | baud_base = 25000000; | ||
411 | div = 48; | ||
412 | /* Set the override bit so we don't divide it */ | ||
413 | chipco_write32(cc, SSB_CHIPCO_CORECTL, | ||
414 | chipco_read32(cc, SSB_CHIPCO_CORECTL) | ||
415 | | SSB_CHIPCO_CORECTL_UARTCLK0); | ||
416 | } else if ((ccrev >= 11) && (ccrev != 15)) { | ||
391 | /* Fixed ALP clock */ | 417 | /* Fixed ALP clock */ |
392 | baud_base = 20000000; | 418 | baud_base = 20000000; |
419 | if (cc->capabilities & SSB_CHIPCO_CAP_PMU) { | ||
420 | /* FIXME: baud_base is different for devices with a PMU */ | ||
421 | SSB_WARN_ON(1); | ||
422 | } | ||
393 | div = 1; | 423 | div = 1; |
424 | if (ccrev >= 21) { | ||
425 | /* Turn off UART clock before switching clocksource. */ | ||
426 | chipco_write32(cc, SSB_CHIPCO_CORECTL, | ||
427 | chipco_read32(cc, SSB_CHIPCO_CORECTL) | ||
428 | & ~SSB_CHIPCO_CORECTL_UARTCLKEN); | ||
429 | } | ||
394 | /* Set the override bit so we don't divide it */ | 430 | /* Set the override bit so we don't divide it */ |
395 | chipco_write32(cc, SSB_CHIPCO_CORECTL, | 431 | chipco_write32(cc, SSB_CHIPCO_CORECTL, |
396 | SSB_CHIPCO_CORECTL_UARTCLK0); | 432 | chipco_read32(cc, SSB_CHIPCO_CORECTL) |
397 | } else if (cc->dev->id.revision >= 3) { | 433 | | SSB_CHIPCO_CORECTL_UARTCLK0); |
434 | if (ccrev >= 21) { | ||
435 | /* Re-enable the UART clock. */ | ||
436 | chipco_write32(cc, SSB_CHIPCO_CORECTL, | ||
437 | chipco_read32(cc, SSB_CHIPCO_CORECTL) | ||
438 | | SSB_CHIPCO_CORECTL_UARTCLKEN); | ||
439 | } | ||
440 | } else if (ccrev >= 3) { | ||
398 | /* Internal backplane clock */ | 441 | /* Internal backplane clock */ |
399 | baud_base = ssb_clockspeed(bus); | 442 | baud_base = ssb_clockspeed(bus); |
400 | div = chipco_read32(cc, SSB_CHIPCO_CLKDIV) | 443 | div = chipco_read32(cc, SSB_CHIPCO_CLKDIV) |
@@ -406,7 +449,7 @@ int ssb_chipco_serial_init(struct ssb_chipcommon *cc, | |||
406 | } | 449 | } |
407 | 450 | ||
408 | /* Clock source depends on strapping if UartClkOverride is unset */ | 451 | /* Clock source depends on strapping if UartClkOverride is unset */ |
409 | if ((cc->dev->id.revision > 0) && | 452 | if ((ccrev > 0) && |
410 | !(chipco_read32(cc, SSB_CHIPCO_CORECTL) & SSB_CHIPCO_CORECTL_UARTCLK0)) { | 453 | !(chipco_read32(cc, SSB_CHIPCO_CORECTL) & SSB_CHIPCO_CORECTL_UARTCLK0)) { |
411 | if ((cc->capabilities & SSB_CHIPCO_CAP_UARTCLK) == | 454 | if ((cc->capabilities & SSB_CHIPCO_CAP_UARTCLK) == |
412 | SSB_CHIPCO_CAP_UARTCLK_INT) { | 455 | SSB_CHIPCO_CAP_UARTCLK_INT) { |
@@ -428,7 +471,7 @@ int ssb_chipco_serial_init(struct ssb_chipcommon *cc, | |||
428 | cc_mmio = cc->dev->bus->mmio + (cc->dev->core_index * SSB_CORE_SIZE); | 471 | cc_mmio = cc->dev->bus->mmio + (cc->dev->core_index * SSB_CORE_SIZE); |
429 | uart_regs = cc_mmio + SSB_CHIPCO_UART0_DATA; | 472 | uart_regs = cc_mmio + SSB_CHIPCO_UART0_DATA; |
430 | /* Offset changed at after rev 0 */ | 473 | /* Offset changed at after rev 0 */ |
431 | if (cc->dev->id.revision == 0) | 474 | if (ccrev == 0) |
432 | uart_regs += (i * 8); | 475 | uart_regs += (i * 8); |
433 | else | 476 | else |
434 | uart_regs += (i * 256); | 477 | uart_regs += (i * 256); |