public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] da830: Move common code out of da830evm.c file
@ 2010-06-01  9:05 Sudhakar Rajashekhara
  2010-06-01 10:01 ` Wolfgang Denk
  0 siblings, 1 reply; 3+ messages in thread
From: Sudhakar Rajashekhara @ 2010-06-01  9:05 UTC (permalink / raw)
  To: u-boot

TI's DA850/OMAP-L138 platform is similar to DA830/OMAP-L137
in many aspects. So instead of repeating the same code in
multiple files, move the common code to a different file
and call those functions from the respective da830/da850
files.

Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
Acked-by: Nick Thompson <nick.thompson@ge.com>
Acked-by: Ben Gardiner <bengardiner@nanometrics.ca>
---
Since v1:
Added irq_init declaration in misc.h to avoid compiler warning.

 board/davinci/common/misc.c       |   30 ++++++++++++++++++++++++++++++
 board/davinci/common/misc.h       |    7 +++++++
 board/davinci/da830evm/da830evm.c |   28 +++++++++++-----------------
 3 files changed, 48 insertions(+), 17 deletions(-)

diff --git a/board/davinci/common/misc.c b/board/davinci/common/misc.c
index 25ca326..412ab50 100644
--- a/board/davinci/common/misc.c
+++ b/board/davinci/common/misc.c
@@ -41,6 +41,22 @@ int dram_init(void)
 	return(0);
 }
 
+void irq_init(void)
+{
+	/*
+	 * Mask all IRQs by clearing the global enable and setting
+	 * the enable clear for all the 90 interrupts.
+	 */
+
+	writel(0, &davinci_aintc_regs->ger);
+
+	writel(0, &davinci_aintc_regs->hier);
+
+	writel(0xffffffff, &davinci_aintc_regs->ecr1);
+	writel(0xffffffff, &davinci_aintc_regs->ecr2);
+	writel(0xffffffff, &davinci_aintc_regs->ecr3);
+}
+
 #ifdef CONFIG_DRIVER_TI_EMAC
 
 /* Read ethernet MAC address from EEPROM for DVEVM compatible boards.
@@ -186,3 +202,17 @@ int davinci_configure_pin_mux_items(const struct pinmux_resource *item,
 
 	return 0;
 }
+
+/*
+ * Enable PSC for various peripherals.
+ */
+int davinci_configure_lpsc_items(const struct lpsc_resource *item,
+				    const int n_items)
+{
+	int i;
+
+	for (i = 0; i < n_items; i++)
+		lpsc_on(item[i].lpsc_no);
+
+	return 0;
+}
diff --git a/board/davinci/common/misc.h b/board/davinci/common/misc.h
index 329c369..ee35f01 100644
--- a/board/davinci/common/misc.h
+++ b/board/davinci/common/misc.h
@@ -45,10 +45,17 @@ struct pinmux_resource {
 				.n_pins = ARRAY_SIZE(item) \
 			  }
 
+struct lpsc_resource {
+	const int	lpsc_no;
+};
+
+void irq_init(void);
 int dvevm_read_mac_address(uint8_t *buf);
 void dv_configure_mac_address(uint8_t *rom_enetaddr);
 int davinci_configure_pin_mux(const struct pinmux_config *pins, int n_pins);
 int davinci_configure_pin_mux_items(const struct pinmux_resource *item,
 				    int n_items);
+int davinci_configure_lpsc_items(const struct lpsc_resource *item,
+				    int n_items);
 
 #endif /* __MISC_H */
diff --git a/board/davinci/da830evm/da830evm.c b/board/davinci/da830evm/da830evm.c
index 6385443..66aabc8 100644
--- a/board/davinci/da830evm/da830evm.c
+++ b/board/davinci/da830evm/da830evm.c
@@ -120,21 +120,18 @@ static const struct pinmux_resource pinmuxes[] = {
 #endif
 };
 
+static const struct lpsc_resource lpsc[] = {
+	DAVINCI_LPSC_AEMIF,	/* NAND, NOR */
+	DAVINCI_LPSC_SPI0,	/* Serial Flash */
+	DAVINCI_LPSC_EMAC,	/* image download */
+	DAVINCI_LPSC_UART2,	/* console */
+	DAVINCI_LPSC_GPIO,
+};
+
 int board_init(void)
 {
 #ifndef CONFIG_USE_IRQ
-	/*
-	 * Mask all IRQs by clearing the global enable and setting
-	 * the enable clear for all the 90 interrupts.
-	 */
-
-	writel(0, &davinci_aintc_regs->ger);
-
-	writel(0, &davinci_aintc_regs->hier);
-
-	writel(0xffffffff, &davinci_aintc_regs->ecr1);
-	writel(0xffffffff, &davinci_aintc_regs->ecr2);
-	writel(0xffffffff, &davinci_aintc_regs->ecr3);
+	irq_init();
 #endif
 
 #ifdef CONFIG_NAND_DAVINCI
@@ -165,11 +162,8 @@ int board_init(void)
 	 * assuming here that the DSP bootloader has set the IOPU
 	 * such that PSC access is available to ARM
 	 */
-	lpsc_on(DAVINCI_LPSC_AEMIF);    /* NAND, NOR */
-	lpsc_on(DAVINCI_LPSC_SPI0);     /* Serial Flash */
-	lpsc_on(DAVINCI_LPSC_EMAC);     /* image download */
-	lpsc_on(DAVINCI_LPSC_UART2);    /* console */
-	lpsc_on(DAVINCI_LPSC_GPIO);
+	if (davinci_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
+		return 1;
 
 	/* setup the SUSPSRC for ARM to control emulation suspend */
 	writel(readl(&davinci_syscfg_regs->suspsrc) &
-- 
1.5.6

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v2] da830: Move common code out of da830evm.c file
  2010-06-01  9:05 [U-Boot] [PATCH v2] da830: Move common code out of da830evm.c file Sudhakar Rajashekhara
@ 2010-06-01 10:01 ` Wolfgang Denk
  2010-06-01 10:18   ` Sudhakar Rajashekhara
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Denk @ 2010-06-01 10:01 UTC (permalink / raw)
  To: u-boot

Dear Sudhakar Rajashekhara,

In message <1275383152-31122-1-git-send-email-sudhakar.raj@ti.com> you wrote:
> TI's DA850/OMAP-L138 platform is similar to DA830/OMAP-L137
> in many aspects. So instead of repeating the same code in
> multiple files, move the common code to a different file
> and call those functions from the respective da830/da850
> files.
> 
> Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
> Acked-by: Nick Thompson <nick.thompson@ge.com>
> Acked-by: Ben Gardiner <bengardiner@nanometrics.ca>
> ---
> Since v1:
> Added irq_init declaration in misc.h to avoid compiler warning.

This patch causes the following compiler warning for me:

-> ./MAKEALL da830evm da850evm
Configuring for da830evm board...
da830evm.c:124: warning: missing braces around initializer
da830evm.c:124: warning: (near initialization for 'lpsc[0]')

122
123 static const struct lpsc_resource lpsc[] = {
124         DAVINCI_LPSC_AEMIF,     /* NAND, NOR */
125         DAVINCI_LPSC_SPI0,      /* Serial Flash */
126         DAVINCI_LPSC_EMAC,      /* image download */
127         DAVINCI_LPSC_UART2,     /* console */
128         DAVINCI_LPSC_GPIO,
129 };



Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Unser Kopf ist rund, damit das Denken die Richtung wechseln kann.
                                                   -- Francis Picabia

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v2] da830: Move common code out of da830evm.c file
  2010-06-01 10:01 ` Wolfgang Denk
@ 2010-06-01 10:18   ` Sudhakar Rajashekhara
  0 siblings, 0 replies; 3+ messages in thread
From: Sudhakar Rajashekhara @ 2010-06-01 10:18 UTC (permalink / raw)
  To: u-boot

Hi,

On Tue, Jun 01, 2010 at 15:31:39, Wolfgang Denk wrote:
> Dear Sudhakar Rajashekhara,
> 
> In message <1275383152-31122-1-git-send-email-sudhakar.raj@ti.com> you wrote:
> > TI's DA850/OMAP-L138 platform is similar to DA830/OMAP-L137
> > in many aspects. So instead of repeating the same code in
> > multiple files, move the common code to a different file
> > and call those functions from the respective da830/da850
> > files.
> > 
> > Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
> > Acked-by: Nick Thompson <nick.thompson@ge.com>
> > Acked-by: Ben Gardiner <bengardiner@nanometrics.ca>
> > ---
> > Since v1:
> > Added irq_init declaration in misc.h to avoid compiler warning.
> 
> This patch causes the following compiler warning for me:
> 
> -> ./MAKEALL da830evm da850evm
> Configuring for da830evm board...
> da830evm.c:124: warning: missing braces around initializer
> da830evm.c:124: warning: (near initialization for 'lpsc[0]')
> 
> 122
> 123 static const struct lpsc_resource lpsc[] = {
> 124         DAVINCI_LPSC_AEMIF,     /* NAND, NOR */
> 125         DAVINCI_LPSC_SPI0,      /* Serial Flash */
> 126         DAVINCI_LPSC_EMAC,      /* image download */
> 127         DAVINCI_LPSC_UART2,     /* console */
> 128         DAVINCI_LPSC_GPIO,
> 129 };
> 

I'll fix this and re-submit the patch.

Thanks,
Sudhakar

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-06-01 10:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-01  9:05 [U-Boot] [PATCH v2] da830: Move common code out of da830evm.c file Sudhakar Rajashekhara
2010-06-01 10:01 ` Wolfgang Denk
2010-06-01 10:18   ` Sudhakar Rajashekhara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox