Skip to contentSkip to conversation

Consolidates ADS5121 IO Pin configuration

PATCH New Martha Marx 3 participants 3 messages May 29, 2008 – Jun 16, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Consolidates ADS5121 IO Pin configuration

---
 board/ads5121/Makefile    |    2 +-
 board/ads5121/ads5121.c   |   36 +-------
 board/ads5121/iopin.c     |   96 ++++++++++++++++++++
 board/ads5121/iopin.h     |  220 +++++++++++++++++++++++++++++++++++++++++++++
 cpu/mpc512x/fec.c         |   15 ---
 include/configs/ads5121.h |    1 +
 6 files changed, 321 insertions(+), 49 deletions(-)
 create mode 100644 board/ads5121/iopin.c
 create mode 100644 board/ads5121/iopin.h
board/ads5121/Makefile +1 -1
index 0e4de61..88da762 100644
@@ -27,7 +27,7 @@ $(shell mkdir -p $(OBJTREE)/board/freescale/common)
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS-y	:= $(BOARD).o
+COBJS-y	:= $(BOARD).o iopin.o
 COBJS-${CONFIG_FSL_DIU_FB} += ads5121_diu.o
 COBJS-${CONFIG_FSL_DIU_FB} += ../freescale/common/fsl_diu_fb.o
 COBJS-$(CONFIG_PCI) += pci.o
board/ads5121/ads5121.c +3 -33
index 95559ca..f6649a6 100644
@@ -47,28 +47,13 @@
 #define CSAW_START(start)	((start) & 0xFFFF0000)
 #define CSAW_STOP(start, size)	(((start) + (size) - 1) >> 16)
 
-#define MPC5121_IOCTL_PSC6_0	(0x284/4)
-#define MPC5121_IO_DIU_START	(0x288/4)
-#define MPC5121_IO_DIU_END	(0x2fc/4)
-
-/* Functional pin muxing */
-#define MPC5121_IO_FUNC1	(0 << 7)
-#define MPC5121_IO_FUNC2	(1 << 7)
-#define MPC5121_IO_FUNC3	(2 << 7)
-#define MPC5121_IO_FUNC4	(3 << 7)
-#define MPC5121_IO_ST		(1 << 2)
-#define MPC5121_IO_DS_1		(0)
-#define MPC5121_IO_DS_2		(1)
-#define MPC5121_IO_DS_3		(2)
-#define MPC5121_IO_DS_4		(3)
-
 long int fixed_sdram(void);
+extern void iopin_initialize(void);
 
 int board_early_init_f (void)
 {
 	volatile immap_t *im = (immap_t *) CFG_IMMR;
 	u32 lpcaw, tmp32;
-	volatile ioctrl512x_t *ioctl = &(im->io_ctrl);
 	int i;
 
 	/*
@@ -114,16 +99,6 @@ int board_early_init_f (void)
 	im->clk.sccr[0] = SCCR1_CLOCKS_EN;
 	im->clk.sccr[1] = SCCR2_CLOCKS_EN;
 
-	/* Configure DIU clock pin */
-	tmp32 = ioctl->regs[MPC5121_IOCTL_PSC6_0];
-	tmp32 &= ~0x1ff;
-	tmp32 |= MPC5121_IO_FUNC3 | MPC5121_IO_DS_4;
-	ioctl->regs[MPC5121_IOCTL_PSC6_0] = tmp32;
-
-	/* Initialize IO pins (pin mux) for DIU function */
-	for (i = MPC5121_IO_DIU_START; i < MPC5121_IO_DIU_END; i++)
-		ioctl->regs[i] |= (MPC5121_IO_FUNC3 | MPC5121_IO_DS_4);
-
 	return 0;
 }
 
@@ -265,17 +240,12 @@ int checkboard (void)
 {
 	ushort brd_rev = *(vu_short *) (CFG_CPLD_BASE + 0x00);
 	uchar cpld_rev = *(vu_char *) (CFG_CPLD_BASE + 0x02);
-	volatile immap_t *im = (immap_t *) CFG_IMMR;
-	volatile unsigned long *reg;
-	int i;
 
 	printf ("Board: ADS5121 rev. 0x%04x (CPLD rev. 0x%02x)\n",
 		brd_rev, cpld_rev);
+	/* initialize function mux & slew rate IO inter alia on IO Pins  */
+	iopin_initialize();
 
-	/* change the slew rate on all pata pins to max */
-	reg = (unsigned long *) &(im->io_ctrl.regs[PATA_CE1_IDX]);
-	for (i = 0; i < 9; i++)
-		reg[i] |= 0x00000003;
 	return 0;
 }
 
board/ads5121/iopin.c new file +96 -0

96 lines not on this page · raw message

board/ads5121/iopin.h new file +220 -0

220 lines not on this page · raw message

cpu/mpc512x/fec.c +0 -15
index c226a8a..e9df7de 100644
@@ -604,13 +604,10 @@ static int mpc512x_fec_recv (struct eth_device *dev)
 /********************************************************************/
 int mpc512x_fec_initialize (bd_t * bis)
 {
-
-	immap_t *im = (immap_t*) CFG_IMMR;
 	mpc512x_fec_priv *fec;
 	struct eth_device *dev;
 	int i;
 	char *tmp, *end, env_enetaddr[6];
-	uint32 *reg;
 	void * bd;
 
 	fec = (mpc512x_fec_priv *) malloc (sizeof(*fec));
@@ -639,18 +636,6 @@ int mpc512x_fec_initialize (bd_t * bis)
 			fec512x_miiphy_read, fec512x_miiphy_write);
 #endif
 
-	/*
-	 * Initialize I\O pins
-	 */
-	reg = (uint32 *) &(im->io_ctrl.regs[PSC0_0_IDX]);
-
-	for (i = 0; i < 15; i++)
-		reg[i] = IOCTRL_MUX_FEC | 0x00000001;
-
-	im->io_ctrl.regs[SPDIF_TXCLOCK_IDX] = IOCTRL_MUX_FEC | 0x00000001;
-	im->io_ctrl.regs[SPDIF_TX_IDX] = IOCTRL_MUX_FEC | 0x00000001;
-	im->io_ctrl.regs[SPDIF_RX_IDX] = IOCTRL_MUX_FEC | 0x00000001;
-
 	/* Clean up space FEC's MIB and FIFO RAM ...*/
 	memset ((void *) MPC512X_FEC + 0x200, 0x00, 0x400);
 
include/configs/ads5121.h +1 -0
index ae98359..50b3512 100644
@@ -27,6 +27,7 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
+#define CONFIG_ADS5121 1
 /*
  * Memory map for the ADS5121 board:
  *
Signature · 1 line
1.5.2.4
#1 lore raw

PATCH 1/1 Consolidates ADS5121 IO Pin configuration

Quoted 11 lines · Martha Marx
---
 board/ads5121/Makefile    |    2 +-
 board/ads5121/ads5121.c   |   36 +-------
 board/ads5121/iopin.c     |   96 ++++++++++++++++++++
 board/ads5121/iopin.h     |  220 +++++++++++++++++++++++++++++++++++++++++++++
 cpu/mpc512x/fec.c         |   15 ---
 include/configs/ads5121.h |    1 +
 6 files changed, 321 insertions(+), 49 deletions(-)
 create mode 100644 board/ads5121/iopin.c
 create mode 100644 board/ads5121/iopin.h

It's good that you remove iomux setting from the drivers like fec it should not be there.

It's NOT good that you now put them in another "driver" iopin.

The pins should be in board specific files. iopin should only contain helper functions not data that everybody that do a new board needs to go in and change/add.

put the table in ads5121.c and I'm happy with it. well I'm not sure we need this fancy stuff only gets harder to read but I take that over having the config spread out over different files like it's now.

#2 lore raw

PATCH 1/1 Consolidates ADS5121 IO Pin configuration

Quoted 3 lines · Kenneth Johansson
Quoted 1 line · Martha Marx
Quoted 16 lines
Quoted 10 lines
---
 board/ads5121/Makefile    |    2 +-
 board/ads5121/ads5121.c   |   36 +-------
 board/ads5121/iopin.c     |   96 ++++++++++++++++++++
 board/ads5121/iopin.h     |  220 +++++++++++++++++++++++++++++++++++++++++++++
 cpu/mpc512x/fec.c         |   15 ---
 include/configs/ads5121.h |    1 +
 6 files changed, 321 insertions(+), 49 deletions(-)
 create mode 100644 board/ads5121/iopin.c
 create mode 100644 board/ads5121/iopin.h

It's good that you remove iomux setting from the drivers like fec it should not be there.

It's NOT good that you now put them in another "driver" iopin.

Quoted 7 lines

The pins should be in board specific files. iopin should only contain helper functions not data that everybody that do a new board needs to go in and change/add.

put the table in ads5121.c and I'm happy with it. well I'm not sure we need this fancy stuff only gets harder to read but I take that over having the config spread out over different files like it's now.

I think this approach is okay. For now it is isolated within the board directory, but it can be factored out into common code where there are a few more 5121 board ports.

Cheers,
g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.