[U-Boot-Users] "7.at91rm9200dk":(1 of 1) [PATCH][ARM] Add PIO control for at91rm9200dk LEDs and Mux.

Ulf Samuelsson ulf at atmel.com
Tue Mar 27 18:17:15 CEST 2007


Author: Ulf Samuelsson <ulf at atmel.com>
Date:     2007-03-27

Subject:	"7.at91rm9200dk":(1 of  1)     [PATCH][ARM] 	Add PIO control for at91rm9200dk LEDs and Mux.

CHANGELOG:
    [PATCH][ARM] 	Add PIO control for at91rm9200dk LEDs and Mux.
    Introduce a new command CFG_CMD_MUX 0x8000000000000000ULL

    Patch generated from files:
          board_at91rm9200dk_led.c.patch
          board_at91rm9200dk_Makefile.patch
          board_at91rm9200dk_mux.c.patch
          common_soft_i2c.c.patch
          include_cmd_confdefs.h.patch
          include_configs_at91rm9200dk.h.patch
          include_led.h.patch

    Signed-off-by:	Ulf Samuelsson
---------------------------------------------------------------------------------------------------------------------------------
diff -urN u-boot-1.2.0/board/at91rm9200dk/led.c u-boot-1.2.0-atmel/board/at91rm9200dk/led.c
--- u-boot-1.2.0/board/at91rm9200dk/led.c	1970-01-01 01:00:00.000000000 +0100
+++ u-boot-1.2.0-atmel/board/at91rm9200dk/led.c	2007-03-27 10:40:35.000000000 +0200
@@ -0,0 +1,81 @@
+/*
+ * (C) Copyright 2006
+ * Atmel Nordic AB <www.atmel.com>
+ * Ulf Samuelsson <ulf at atmel.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/arch/AT91RM9200.h>
+
+#define	GREEN_LED	AT91C_PIO_PB0
+#define	YELLOW_LED	AT91C_PIO_PB1
+#define	RED_LED	AT91C_PIO_PB2
+
+void	green_LED_on(void)
+{
+	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
+	PIOB->PIO_CODR		= GREEN_LED;
+}
+
+void	 yellow_LED_on(void)
+{
+	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
+	PIOB->PIO_CODR		= YELLOW_LED;
+}
+
+void	 red_LED_on(void)
+{
+	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
+	PIOB->PIO_CODR		= RED_LED;
+}
+
+void	green_LED_off(void)
+{
+	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
+	PIOB->PIO_SODR		= GREEN_LED;
+}
+
+void	yellow_LED_off(void)
+{
+	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
+	PIOB->PIO_SODR		= YELLOW_LED;
+}
+
+void	red_LED_off(void)
+{
+	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
+	PIOB->PIO_SODR		= RED_LED;
+}
+
+
+void LED_init (void)
+{
+	DECLARE_GLOBAL_DATA_PTR;
+	AT91PS_PIO	PIOB	= AT91C_BASE_PIOB;
+	AT91PS_PMC	PMC	= AT91C_BASE_PMC;
+	PMC->PMC_PCER		= (1 << AT91C_ID_PIOB);	/* Enable PIOB clock */
+	/* Disable peripherals on LEDs */
+	PIOB->PIO_PER		= AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0;
+	/* Enable pins as outputs */
+	PIOB->PIO_OER		= AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0;
+	/* Turn all LEDs OFF */
+	PIOB->PIO_SODR		= AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0;
+}
diff -urN u-boot-1.2.0/board/at91rm9200dk/Makefile u-boot-1.2.0-atmel/board/at91rm9200dk/Makefile
--- u-boot-1.2.0/board/at91rm9200dk/Makefile	2007-03-27 09:30:38.000000000 +0200
+++ u-boot-1.2.0-atmel/board/at91rm9200dk/Makefile	2007-03-24 20:07:33.000000000 +0100
@@ -25,7 +25,7 @@

 LIB	= $(obj)lib$(BOARD).a

-COBJS	:= at91rm9200dk.o flash.o
+COBJS	:= at91rm9200dk.o flash.o led.o mux.o

 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
diff -urN u-boot-1.2.0/board/at91rm9200dk/mux.c u-boot-1.2.0-atmel/board/at91rm9200dk/mux.c
--- u-boot-1.2.0/board/at91rm9200dk/mux.c	1970-01-01 01:00:00.000000000 +0100
+++ u-boot-1.2.0-atmel/board/at91rm9200dk/mux.c	2007-03-24 20:07:33.000000000 +0100
@@ -0,0 +1,36 @@
+#include <config.h>
+#include <common.h>
+#include <asm/hardware.h>
+#include <dataflash.h>
+
+int AT91F_GetMuxStatus(void) {
+#ifdef	DATAFLASH_MMC_SELECT
+		AT91C_BASE_PIOB->PIO_PER = DATAFLASH_MMC_SELECT;	/* Set in PIO mode */
+		AT91C_BASE_PIOB->PIO_OER = DATAFLASH_MMC_SELECT;	/* Configure in output */
+
+
+		if(AT91C_BASE_PIOB->PIO_ODSR & DATAFLASH_MMC_SELECT) {
+			return 1;
+		} else {
+			return 0;
+		}
+#endif
+}
+
+void AT91F_SelectMMC(void) {
+#ifdef	DATAFLASH_MMC_SELECT
+		AT91C_BASE_PIOB->PIO_PER = DATAFLASH_MMC_SELECT;	/* Set in PIO mode */
+		AT91C_BASE_PIOB->PIO_OER = DATAFLASH_MMC_SELECT;	/* Configure in output */
+		/* Set Output */
+		AT91C_BASE_PIOB->PIO_SODR = DATAFLASH_MMC_SELECT;
+#endif
+}
+
+void AT91F_SelectSPI(void) {
+#ifdef	DATAFLASH_MMC_SELECT
+		AT91C_BASE_PIOB->PIO_PER = DATAFLASH_MMC_SELECT;	/* Set in PIO mode */
+		AT91C_BASE_PIOB->PIO_OER = DATAFLASH_MMC_SELECT;	/* Configure in output */
+		/* Clear Output */
+		AT91C_BASE_PIOB->PIO_CODR = DATAFLASH_MMC_SELECT;
+#endif
+}
diff -urN u-boot-1.2.0/common/soft_i2c.c u-boot-1.2.0-atmel/common/soft_i2c.c
--- u-boot-1.2.0/common/soft_i2c.c	2007-01-07 00:13:11.000000000 +0100
+++ u-boot-1.2.0-atmel/common/soft_i2c.c	2007-03-24 20:07:33.000000000 +0100
@@ -29,7 +29,7 @@
 #ifdef	CONFIG_MPC8260			/* only valid for MPC8260 */
 #include <ioports.h>
 #endif
-#ifdef CONFIG_AT91RM9200DK		/* need this for the at91rm9200dk */
+#ifdef	CONFIG_AT91RM9200		/* need this for the at91rm9200 */
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
 #endif
diff -urN u-boot-1.2.0/include/cmd_confdefs.h u-boot-1.2.0-atmel/include/cmd_confdefs.h
--- u-boot-1.2.0/include/cmd_confdefs.h	2007-01-07 00:13:11.000000000 +0100
+++ u-boot-1.2.0-atmel/include/cmd_confdefs.h	2007-03-24 20:07:33.000000000 +0100
@@ -94,6 +94,7 @@
 #define CFG_CMD_EXT2	0x1000000000000000ULL	/* EXT2 Support			*/
 #define CFG_CMD_SNTP	0x2000000000000000ULL	/* SNTP support			*/
 #define CFG_CMD_DISPLAY	0x4000000000000000ULL	/* Display support		*/
+#define CFG_CMD_MUX     0x8000000000000000ULL	/* AT91 MMC/SPI Mux Support     */

 #define CFG_CMD_ALL	0xFFFFFFFFFFFFFFFFULL	/* ALL commands			*/

@@ -141,7 +142,8 @@
 			CFG_CMD_SPI	| \
 			CFG_CMD_UNIVERSE | \
 			CFG_CMD_USB	| \
-			CFG_CMD_VFD	)
+			CFG_CMD_VFD	| \
+			CFG_CMD_MUX)

 /* Default configuration
  */
diff -urN u-boot-1.2.0/include/configs/at91rm9200dk.h u-boot-1.2.0-atmel/include/configs/at91rm9200dk.h
--- u-boot-1.2.0/include/configs/at91rm9200dk.h	2007-01-07 00:13:11.000000000 +0100
+++ u-boot-1.2.0-atmel/include/configs/at91rm9200dk.h	2007-03-26 22:40:12.000000000 +0200
@@ -150,6 +162,11 @@
 #define CONFIG_NET_RETRY_COUNT		20
 #define CONFIG_AT91C_USE_RMII

+/* AC Characteristics */
+/* DLYBS = tCSS = 250ns min and DLYBCT = tCSH = 250ns */
+#define DATAFLASH_TCSS	(0xC << 16)
+#define DATAFLASH_TCHS	(0x1 << 24)
+
 #define CONFIG_HAS_DATAFLASH		1
 #define CFG_SPI_WRITE_TOUT		(5*CFG_HZ)
 #define CFG_MAX_DATAFLASH_BANKS 	2
diff -urN u-boot-1.2.0/include/led.h u-boot-1.2.0-atmel/include/led.h
--- u-boot-1.2.0/include/led.h	1970-01-01 01:00:00.000000000 +0100
+++ u-boot-1.2.0-atmel/include/led.h	2007-03-24 20:07:32.000000000 +0100
@@ -0,0 +1,45 @@
+/*
+ * (C) Copyright 2006
+ * Atmel Nordic AB <www.atmel.com>
+ * Ulf Samuelsson <ulf at atmel.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+ #ifndef __LED_H
+#define __LED_H
+
+#ifndef	__ASSEMBLY__
+extern void	LED_init (void);
+extern void	red_LED_on(void);
+extern void	red_LED_off(void);
+extern void	green_LED_on(void);
+extern void	green_LED_off(void);
+extern void	yellow_LED_on(void);
+extern void	yellow_LED_off(void);
+#else
+	.extern LED_init
+	.extern red_LED_on
+	.extern red_LED_off
+	.extern yellow_LED_on
+	.extern yellow_LED_off
+	.extern green_LED_on
+	.extern green_LED_off
+#endif
+#endif

-- 
Best Regards,
Ulf Samuelsson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ulf.vcf
Type: text/x-vcard
Size: 301 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20070327/bccb2768/attachment.vcf 


More information about the U-Boot mailing list