Skip to contentSkip to conversation

CPCI405 update

PATCH New Stefan Roese 1 participant 1 message Mar 26, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CPCI405 update

Hello

The attached patch fixes a baudrate problem with the 400MHz version of the PPC405GPr on the CPCI405 board.

- Added cpci405_early_serial_map (cloned from evb405ep) to generate BASE_BAUD dynamically from the UDIV settings (configured by U-Boot).

Please apply this patch to linuxppc_2_4_devel.

Best regards,
Stefan.

arch/ppc/platforms/cpci405.c +1 -1
diff -N -u -r --exclude=CVS --exclude=LOG linuxppc_2_4_devel_2.4.21pre5_orig/arch/ppc/platforms/cpci405.c linuxppc_2_4_devel_2.4.21pre5/arch/ppc/platforms/cpci405.c
@@ -6,7 +6,7 @@
  * Author: Stefan Roese
  *         [email protected]
  *
- * Copyright 2001 esd electronic system design - hannover germany
+ * Copyright 2001-2003 esd electronic system design - hannover germany
  *
  * This program is free software; you can redistribute  it and/or modify it
  * under  the terms of  the GNU General Public License as published by the

409/2001 - armin
* added board_init to add in additional instuctions needed during platfrom_init
*
+ * : 03/26/03 - stefan
+ * Added cpci405_early_serial_map (cloned from evb405ep) to generate
+ * BASE_BAUD dynamically from the UDIV settings (configured by U-Boot).
+ *
*/

#include <linux/config.h>
3pci-bridge.h>
#include <asm/machdep.h>
#include <asm/todc.h>
+#include <linux/serial.h>

-void *cpci405_nvram;
+void *cpci405_nvram;

/*
* Some IRQs unique to CPCI-405.
2_TABLE_LOOKUP;
};

+/* The serial clock for the chip is an internal clock determined by
+ * different clock speeds/dividers.
+ * Calculate the proper input baud rate and setup the serial driver.
+ */
+static void __init
+cpci405_early_serial_map(void)
+{
+ u32 uart_div;
+ int serial_baud_405;
+ bd_t *bip = (bd_t *) __res;
+ struct serial_struct serialreq = {0};
+
+ /* Calculate the serial clock input frequency

+          *
+          * The base baud is the PLL OUTA (provided in the board info
+          * structure) divided by the external UART Divisor, divided
+          * by 16.
+          */

+ uart_div = (mfdcr(DCRN_CHCR_BASE) & CHR0_UDIV) >> 1;
+ serial_baud_405 = bip->bi_procfreq / uart_div / 16;
+
+ /* Update the serial port attributes */
+ serialreq.baud_base = serial_baud_405;
+ serialreq.flags = (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST);
+ serialreq.io_type = SERIAL_IO_MEM;
+
+ serialreq.line = 0;
+ serialreq.port = 0;
+ serialreq.irq = ACTING_UART0_INT;
+ serialreq.iomem_base = (void*)ACTING_UART0_IO_BASE;
+
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
+ /* Configure debug serial access */
+ gen550_init(0, &serialreq);
+#endif
+
+ if (early_serial_setup(&serialreq) != 0) {
+ printk("Early serial init of port 0 failed\n");
+ }
+
+ serialreq.line = 1;
+ serialreq.port = 1;
+ serialreq.irq = ACTING_UART1_INT;
+ serialreq.iomem_base = (void*)ACTING_UART1_IO_BASE;
+
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
+ /* Configure debug serial access */
+ gen550_init(1, &serialreq);
+#endif
+
+ if (early_serial_setup(&serialreq) != 0) {
+ printk("Early serial init of port 1 failed\n");
+ }
+}
+
void __init
board_setup_arch(void)
{
+ cpci405_early_serial_map();
TODC_INIT(TODC_TYPE_MK48T35, cpci405_nvram, cpci405_nvram, cpci405_nvram, 8);
}

arch/ppc/platforms/cpci405.h +0 -0
diff -N -u -r --exclude=CVS --exclude=LOG linuxppc_2_4_devel_2.4.21pre5_orig/arch/ppc/platforms/cpci405.h linuxppc_2_4_devel_2.4.21pre5/arch/ppc/platforms/cpci405.h

2NVRAM_PADDR ((uint)0xf0200000)
#define CPCI405_NVRAM_SIZE ((uint)32*1024)

-#ifdef CONFIG_PPC405GP_INTERNAL_CLOCK
-#define BASE_BAUD 201600
+#if defined(CONFIG_UART0_TTYS0)
+#define ACTING_UART0_IO_BASE UART0_IO_BASE
+#define ACTING_UART1_IO_BASE UART1_IO_BASE
+#define ACTING_UART0_INT UART0_INT
+#define ACTING_UART1_INT UART1_INT
#else
-#define BASE_BAUD 691200
+#define ACTING_UART0_IO_BASE UART1_IO_BASE
+#define ACTING_UART1_IO_BASE UART0_IO_BASE
+#define ACTING_UART0_INT UART1_INT
+#define ACTING_UART1_INT UART0_INT
#endif
+
+/* The UART clock is based off an internal clock -
+ * define BASE_BAUD based on the internal clock and divider(s).
+ * Since BASE_BAUD must be a constant, we will initialize it
+ * using clock/divider values which U-Boot initializes
+ * for typical configurations at various CPU speeds.
+ * The base baud is calculated as (FWDA / EXT UART DIV / 16)
+ */
+#define BASE_BAUD 0

#define PPC4xx_MACHINE_NAME "esd CPCI-405"