Blackfin: enable --gc-sections
[oweals/u-boot.git] / cpu / blackfin / serial.h
index 1f0f4b46c7df1793ff07671f90b0a308e2877d3d..f671096768b6b0bffce7ff5984335bb2b85da4c0 100644 (file)
 #include <asm/blackfin.h>
 #include <asm/mach-common/bits/uart.h>
 
+#ifndef CONFIG_UART_CONSOLE
+# define CONFIG_UART_CONSOLE 0
+#endif
+
 #ifdef CONFIG_DEBUG_EARLY_SERIAL
 # define BFIN_DEBUG_EARLY_SERIAL 1
 #else
 __attribute__((always_inline))
 static inline void serial_do_portmux(void)
 {
-#ifdef __ADSPBF52x__
+#if defined(__ADSPBF51x__)
+# define DO_MUX(port, mux_tx, mux_rx, tx, rx) \
+       bfin_write_PORT##port##_MUX((bfin_read_PORT##port##_MUX() & ~(PORT_x_MUX_##mux_tx##_MASK | PORT_x_MUX_##mux_rx##_MASK)) | PORT_x_MUX_##mux_tx##_FUNC_2 | PORT_x_MUX_##mux_rx##_FUNC_2); \
+       bfin_write_PORT##port##_FER(bfin_read_PORT##port##_FER() | P##port##tx | P##port##rx);
+       switch (CONFIG_UART_CONSOLE) {
+       case 0: DO_MUX(G, 5, 5, 9, 10);  break; /* Port G; mux 5; PG9 and PG10 */
+       case 1: DO_MUX(F, 2, 3, 14, 15); break; /* Port H; mux 2/3; PH14 and PH15 */
+       }
+       SSYNC();
+#elif defined(__ADSPBF52x__)
 # define DO_MUX(port, mux, tx, rx) \
        bfin_write_PORT##port##_MUX((bfin_read_PORT##port##_MUX() & ~PORT_x_MUX_##mux##_MASK) | PORT_x_MUX_##mux##_FUNC_3); \
        bfin_write_PORT##port##_FER(bfin_read_PORT##port##_FER() | P##port##tx | P##port##rx);
@@ -175,11 +188,11 @@ static inline uint32_t serial_early_get_baud(void)
 __attribute__((always_inline))
 static inline void serial_early_set_baud(uint32_t baud)
 {
-       /* Translate from baud into divisor in terms of SCLK.
-        * The +1 is to make sure we over sample just a little
-        * rather than under sample the incoming signals.
+       /* Translate from baud into divisor in terms of SCLK.  The
+        * weird multiplication is to make sure we over sample just
+        * a little rather than under sample the incoming signals.
         */
-       uint16_t divisor = (get_sclk() / (baud * 16)) + 1;
+       uint16_t divisor = (get_sclk() + (baud * 8)) / (baud * 16) - ANOMALY_05000230;
 
        /* Set DLAB in LCR to Access DLL and DLH */
        ACCESS_LATCH();