[FE training-materials-updates] Kernel serial lab: simplify DT definitions

Michael Opdenacker michael.opdenacker at free-electrons.com
Tue Feb 4 22:04:58 CET 2014


Repository : git://git.free-electrons.com/training-materials.git

On branch  : master
Link       : http://git.free-electrons.com/training-materials/commit/?id=347d672806655465440881907f9cabf6b61c2652

>---------------------------------------------------------------

commit 347d672806655465440881907f9cabf6b61c2652
Author: Michael Opdenacker <michael.opdenacker at free-electrons.com>
Date:   Tue Feb 4 22:02:54 2014 +0100

    Kernel serial lab: simplify DT definitions
    
    - Instead of using completely new nodes, just redefine
      the existing uart2 and uart4 ones, using phandles.
    
    - Reduce indentation in the dts snippets
    
    Signed-off-by: Michael Opdenacker <michael.opdenacker at free-electrons.com>


>---------------------------------------------------------------

347d672806655465440881907f9cabf6b61c2652
 labs/kernel-serial-iomem/kernel-serial-iomem.tex |   22 +++++++++++------
 labs/kernel-serial-iomem/uarts-pinctrl.dts       |   28 +++++++++++-----------
 labs/kernel-serial-iomem/uarts.dts               |   23 +++++-------------
 3 files changed, 35 insertions(+), 38 deletions(-)

diff --git a/labs/kernel-serial-iomem/kernel-serial-iomem.tex b/labs/kernel-serial-iomem/kernel-serial-iomem.tex
index cb40886..a4877f7 100644
--- a/labs/kernel-serial-iomem/kernel-serial-iomem.tex
+++ b/labs/kernel-serial-iomem/kernel-serial-iomem.tex
@@ -51,25 +51,33 @@ Now, open the \code{arch/arm/boot/dts/am335x-bone-common.dtsi}
 file and create declarations for UART2 and UART4 in the pin muxing
 section:
 
-\sourcecode{labs/kernel-serial-iomem/uarts-pinctrl.dts}
+{\small \sourcecode{labs/kernel-serial-iomem/uarts-pinctrl.dts}}
 
 Then, declare the corresponding devices:
 
 \sourcecode{labs/kernel-serial-iomem/uarts.dts}
 
-Note: we are calling these devices with \code{uartfe} instead of
-\code{uart} to avoid conflicts with declarations in
-\code{arch/arm/boot/dts/am33xx.dtsi}. The \code{uart} devices are 
-meant to be used by the regular serial driver.
+This is a good example of how we can override definitions in the Device
+Tree. \code{uart2} and \code{uart4} are already defined in 
+\code{arch/arm/boot/dts/am33xx.dtsi}. In the above code, we just
+override a few properties and add missing ones. We don't have to 
+duplicate the valid ones:
 
-We will see how to use the device parameters in the driver code.
+\begin{itemize}
+\item \code{compatible}: use our driver instead of using the default one
+      (\code{omap3-uart}). 
+\item \code{status}: enabled the device (was set to \code{disabled} in
+      the original definition.
+\item \code{pinctrl-names}, \code{pinctrl-0}: add pinmux settings
+      (none were defined so far).
+\end{itemize}
 
 Rebuild and update your DTB.
 
 \section{Operate a platform device driver}
 
 Go to the \code{~/felabs/linux/modules/nfsroot/root/serial/} directory.
-You will find a \code{feserial.c} file already provides a platform
+You will find a \code{feserial.c} file which already provides a platform
 driver skeleton.
 
 Add the code needed to match the driver with the devices which you have
diff --git a/labs/kernel-serial-iomem/uarts-pinctrl.dts b/labs/kernel-serial-iomem/uarts-pinctrl.dts
index 66ccca2..2c3cb07 100644
--- a/labs/kernel-serial-iomem/uarts-pinctrl.dts
+++ b/labs/kernel-serial-iomem/uarts-pinctrl.dts
@@ -1,15 +1,15 @@
-	/* Pins 21 (TX) and 22 (RX) of connector P9 */
-	uart2_pins: uart2_pins {
-		pinctrl-single,pins = <
-			0x154 (PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* spi0_d0.uart2_tx, MODE 1 */
-			0x150 (PIN_INPUT_PULLUP | MUX_MODE1) /* spi0_sclk.uart2_rx, MODE 1 */
-		>;
-	};
+/* Pins 21 (TX) and 22 (RX) of connector P9 */
+uart2_pins: uart2_pins {
+	pinctrl-single,pins = <
+		0x154 (PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* spi0_d0.uart2_tx, MODE 1 */
+		0x150 (PIN_INPUT_PULLUP | MUX_MODE1) /* spi0_sclk.uart2_rx, MODE 1 */
+	>;
+};
 
-	/* Pins 11 (RX) and 13 (TX) of connector P9 */
-	uart4_pins: uart4_pins {
-		pinctrl-single,pins = <
-			0x74 (PIN_OUTPUT_PULLDOWN | MUX_MODE6) /* gpmc_wpn.uart4_tx, MODE 6 */
-			0x70 (PIN_INPUT_PULLUP | MUX_MODE6) /* gpmc_wait0.uart4_rx, MODE 6 */
-		>;
-	};
+/* Pins 11 (RX) and 13 (TX) of connector P9 */
+uart4_pins: uart4_pins {
+	pinctrl-single,pins = <
+		0x74 (PIN_OUTPUT_PULLDOWN | MUX_MODE6) /* gpmc_wpn.uart4_tx, MODE 6 */
+		0x70 (PIN_INPUT_PULLUP | MUX_MODE6) /* gpmc_wait0.uart4_rx, MODE 6 */
+	>;
+};
diff --git a/labs/kernel-serial-iomem/uarts.dts b/labs/kernel-serial-iomem/uarts.dts
index bf868cd..f3012c7 100644
--- a/labs/kernel-serial-iomem/uarts.dts
+++ b/labs/kernel-serial-iomem/uarts.dts
@@ -1,24 +1,13 @@
-    uartfe2: feserial at 48024000 {
-        compatible = "free-electrons,serial";
-        /* Tell the OMAP hardware power management that the block
-           must be enabled, otherwise it's switched off
-           Caution: starting counting at 1, not 0 */
-        ti,hwmods = "uart3";
-        clock-frequency = <48000000>;
-        reg = <0x48024000 0x2000>;
-        interrupts = <74>;
+&uart2 {
+	compatible = "free-electrons,serial";
         status = "okay";
         pinctrl-names = "default";
         pinctrl-0 = <&uart2_pins>;
-    };
+};
 
-    uartfe4: feserial at 481a8000 {
-        compatible = "free-electrons,serial";
-        ti,hwmods = "uart5";
-        clock-frequency = <48000000>;
-        reg = <0x481a8000 0x2000>;
-        interrupts = <45>;
+&uart4 {
+	compatible = "free-electrons,serial";
         status = "okay";
         pinctrl-names = "default";
         pinctrl-0 = <&uart4_pins>;
-    };
+};



More information about the training-materials-updates mailing list