svn commit: r192133 - projects/mips/sys/mips/atheros

Oleksandr Tymoshenko gonzo at FreeBSD.org
Fri May 15 01:54:33 UTC 2009


Author: gonzo
Date: Fri May 15 01:54:32 2009
New Revision: 192133
URL: http://svn.freebsd.org/changeset/base/192133

Log:
  - Calculate clock frequency using PLL registers
  - Remove stale comments

Modified:
  projects/mips/sys/mips/atheros/uart_cpu_ar71xx.c

Modified: projects/mips/sys/mips/atheros/uart_cpu_ar71xx.c
==============================================================================
--- projects/mips/sys/mips/atheros/uart_cpu_ar71xx.c	Fri May 15 01:53:09 2009	(r192132)
+++ projects/mips/sys/mips/atheros/uart_cpu_ar71xx.c	Fri May 15 01:54:32 2009	(r192133)
@@ -53,27 +53,34 @@ uart_cpu_eqres(struct uart_bas *b1, stru
 int
 uart_cpu_getdev(int devtype, struct uart_devinfo *di)
 {
+	uint32_t pll_config, div;
+	uint64_t freq;
+
+	/* PLL freq */
+	pll_config = ATH_READ_REG(AR71XX_PLL_CPU_CONFIG);
+	div = ((pll_config >> PLL_FB_SHIFT) & PLL_FB_MASK) + 1;
+	freq = div * AR71XX_BASE_FREQ;
+	/* CPU freq */
+	div = ((pll_config >> PLL_CPU_DIV_SEL_SHIFT) & PLL_CPU_DIV_SEL_MASK) 
+	    + 1;
+	freq = freq / div;
+	/* AHB freq */
+	div = (((pll_config >> PLL_AHB_DIV_SHIFT) & PLL_AHB_DIV_MASK) + 1) * 2;
+	freq = freq / div;
+
 	di->ops = uart_getops(&uart_ns8250_class);
 	di->bas.chan = 0;
 	di->bas.bst = ar71xx_bus_space_reversed;
 	di->bas.regshft = 2;
-	/* TODO: calculate proper AHB freq using PLL registers */
-	di->bas.rclk = 85000000;
+	di->bas.rclk = freq;
 	di->baudrate = 115200;
 	di->databits = 8;
 	di->stopbits = 1;
+
 	di->parity = UART_PARITY_NONE;
 
-	/* TODO: check if uart_bus_space_io mandatory to set */
 	uart_bus_space_io = NULL;
 	uart_bus_space_mem = ar71xx_bus_space_reversed;
-	/* 
-	 * FIXME:
-	 * 3 is to compensate big endian, uart operates 
-	 * with bus_space_read_1/bus_space_write_1 and hence gets 
-	 * highest byte instead of lowest one. Actual fix will involve
-	 * MIPS bus_space fixing.
-	 */
 	di->bas.bsh = MIPS_PHYS_TO_KSEG1(AR71XX_UART_ADDR);
 	return (0);
 }


More information about the svn-src-projects mailing list