Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Feb 2013 18:23:47 +0000
From:      Iain Young <iain@g7iii.net>
To:        Tim Kientzle <tim@kientzle.com>
Cc:        freebsd-arm@freebsd.org, Damjan Marion <dmarion@freebsd.org>
Subject:   Re: Beaglebone Serial Ports Progress
Message-ID:  <5123C333.5090602@g7iii.net>
In-Reply-To: <73B8F088-EE5C-471D-AEED-52D4E45153DA@kientzle.com>
References:  <511E1A08.4020105@g7iii.net> <C54B5EBA-84A1-4BD9-AD7B-B61D7401E4F1@freebsd.org> <5120A7AD.40903@g7iii.net> <73B8F088-EE5C-471D-AEED-52D4E45153DA@kientzle.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------030408000305050501040908
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

On 17/02/13 18:21, Tim Kientzle wrote:

>>
>> Before I send the full patch what are the FreeBSD standards wrt the
>> above lines in am335x_prcm_attach() ? Should I leave as is ? Create
>> a separate function, and call it from am335x_prcm_attach() ? Or do I
>> create a #define in the same file, and create functions for each UART,
>> as I see some other clocks do ?
>
> It would require a little more work but I think the natural
> place to put this would be to put
>
>      uart1: serial@48022000 {
>         ...
>         clocks = "UART1";
>         clock-parent = <&PRCM>;
>      };
>
> in the FDT (which is a straightforward way of
> saying "this device needs the PRCM to turn on
> "UART1" clocks) and then figure out how to
> actually support it.  ;-)
>
> This is the same issue that we've been discussing
> for pinmux, and the above is essentially the same solution
> being discussed for pinmux.
>
> It's not yet clear to me where/how this info should be acted on.
> It could actually be handled in the simplebus driver, I
> think, without modifying (in this case) the UART driver code
> at all.   That would need only a standard way for simplebus to
> communicate the clock-init string to the designated
> clock handler.

In that case, I shall leave things as they are for now, until a
consensus is come to, and other, better kernel coders than I
have written the necessary glue :)

In the meantime, the patch is attached here for anyone that wants
to use the other 5 UARTS (note UART3's TX and RX lines are not
brought out, but it's CTS and RTS lines can still be used for
other things.

The patch is in two parts, one for beaglebone.dts, and one for 
am335x_prcm.c. You need to apply both. patch -p0 from /usr/src
or patch -p1 from /usr/src/sys should suffice.

Thanks to all those that helped point me in the right direction,
I couldn't have got the UARTs  working without your help.

Iain




--------------030408000305050501040908
Content-Type: text/x-patch;
 name="beaglebone.dts.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="beaglebone.dts.patch"

--- sys/boot/fdt/dts/beaglebone.dts.orig	2013-02-19 17:59:18.000000000 +0000
+++ sys/boot/fdt/dts/beaglebone.dts.irp	2013-02-19 17:53:38.000000000 +0000
@@ -39,6 +39,11 @@
 	aliases {
 		soc = &SOC;
 		uart0 = &uart0;
+		uart1 = &uart1;
+		uart2 = &uart2;
+		uart3 = &uart3;
+		uart4 = &uart4;
+		uart5 = &uart5;
 	};
 
 	memory {
@@ -127,6 +132,14 @@
 				"LCD_DATA5", "gpio2_11", "input_pulldown", 
 				"LCD_DATA6", "gpio2_12", "input_pulldown", 
 				"LCD_DATA7", "gpio2_13", "input_pulldown", 
+				"LCD_DATA8", "uart5_txd","output",
+				"LCD_DATA9", "uart5_rxd","input_pulldown",
+				"LCD_DATA10", "uart3_ctsn", "input_pulldown", 
+				"LCD_DATA11", "uart3_rtsn", "output", 
+				"LCD_DATA12", "uart4_ctsn", "input_pulldown", 
+				"LCD_DATA13", "uart4_rtsn", "output", 
+				"LCD_DATA14", "uart5_ctsn", "input_pulldown", 
+				"LCD_DATA15", "uart5_rtsn", "output", 
 				"LCD_VSYNC", "gpio2_22", "input_pulldown",
 				"LCD_HSYNC", "gpio2_23", "input_pulldown",
 				"LCD_PCLK", "gpio2_24", "input_pulldown",
@@ -142,7 +155,20 @@
 				"GPMC_A2", "ehrpwm1A", "output",
 				"GPMC_A3", "ehrpwm1B", "output",
 				"GPMC_AD8", "ehrpwm2A", "output",
-				"GPMC_AD9", "ehrpwm2B", "output";
+				"GPMC_AD9", "ehrpwm2B", "output",
+				"I2C2_SCL","uart1_rtsn","output",
+				"I2C2_SDA","uart1_ctsn","input_pulldown",
+				"UART1_RXD","uart1_rxd","input",
+				"UART1_TXD","uart1_txd","output",
+				"SPI0_D0","uart2_txd","output",
+				"SPI0_SCLK","uart2_rxd","input_pulldown",
+				"UART2_RXD","uart2_rxd","input_pulldown",
+				"GPMC_WAIT0","uart4_rxd","input_pulldown",
+				"GPMC_WPN","uart4_txd","output",
+				"UART5_TXD","uart2_ctsn","input_pulldown",
+				"UART5_RXD","uart2_rtsn","output";
+
+
 		};
 
 		prcm@44E00000 {
@@ -187,7 +213,52 @@
 			reg-shift = <2>;
 			interrupts = < 72 >;
 			interrupt-parent = <&AINTC>;
-			clock-frequency = < 48000000 >; /* FIXME */
+			clock-frequency = < 48000000 >;
+		};
+		
+		uart1: serial@48022000 {
+			compatible = "ns16550";
+			reg = <0x48022000 0x1000>;
+			reg-shift = <2>;
+			interrupts = < 73 >;
+			interrupt-parent = <&AINTC>;
+			clock-frequency = < 48000000 >; 
+		};
+		
+		uart2: serial@48024000 {
+			compatible = "ns16550";
+			reg = <0x48024000 0x1000>;
+			reg-shift = <2>;
+			interrupts = < 74 >;
+			interrupt-parent = <&AINTC>;
+			clock-frequency = < 48000000 >; 
+		};
+		
+		uart3: serial@481a6000 {
+			compatible = "ns16550";
+			reg = <0x481A6000 0x1000>;
+			reg-shift = <2>;
+			interrupts = < 44 >;
+			interrupt-parent = <&AINTC>;
+			clock-frequency = < 48000000 >; 
+		};
+
+		uart4: serial@481a8000 {
+			compatible = "ns16550";
+			reg = <0x481A8000 0x1000>;
+			reg-shift = <2>;
+			interrupts = < 45 >;
+			interrupt-parent = <&AINTC>;
+			clock-frequency = < 48000000 >; 
+		};
+
+		uart5: serial@481a8000 {
+			compatible = "ns16550";
+			reg = <0x481AA000 0x1000>;
+			reg-shift = <2>;
+			interrupts = < 46 >;
+			interrupt-parent = <&AINTC>;
+			clock-frequency = < 48000000 >; 
 		};
 
 		edma3@49000000 {

--------------030408000305050501040908
Content-Type: text/x-patch;
 name="am335x_prcm_uart_clks.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="am335x_prcm_uart_clks.patch"

--- sys/arm/ti/am335x/am335x_prcm.c.orig	2013-02-19 18:03:48.000000000 +0000
+++ sys/arm/ti/am335x/am335x_prcm.c	2013-02-19 18:03:42.000000000 +0000
@@ -314,6 +314,12 @@
 	device_printf(dev, "Clocks: System %u.%01u MHz, CPU %u MHz\n",
 		sysclk/1000000, (sysclk % 1000000)/100000, fclk/1000000);
 
+	prcm_write_4(0x6c, 2); /* UART 1 ENABLE */
+	prcm_write_4(0x70, 2); /* UART 2 ENABLE */
+	prcm_write_4(0x74, 2); /* UART 3 ENABLE */
+	prcm_write_4(0x78, 2); /* UART 4 ENABLE */
+	prcm_write_4(0x38, 2); /* UART 5 ENABLE */
+
 	return (0);
 }
 

--------------030408000305050501040908--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5123C333.5090602>