public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2]ppc4xx/Canyonlands added USB board callbacks
@ 2010-07-07 10:49 Rupjyoti Sarmah
  2010-07-07 11:05 ` Stefan Roese
  2010-07-07 11:13 ` Felix Radensky
  0 siblings, 2 replies; 4+ messages in thread
From: Rupjyoti Sarmah @ 2010-07-07 10:49 UTC (permalink / raw)
  To: u-boot

Functions added to support board callbacks for USB init. This
isolates USB manipulations such that it is only touched if USB is
used by U-Boot.

Signed-off-by: Dave Mitchell <dmitchell@appliedmicro.com>
Signed-off-by: Rupjyoti Sarmah <rsarmah@appliedmicro.com>
---
This patch incorporates the changes advised.
The description of the Macros changed in the header file.

 board/amcc/canyonlands/canyonlands.c |   64 +++++++++++++++++++++++++++++-----
 include/configs/canyonlands.h        |   13 +++++++
 2 files changed, 68 insertions(+), 9 deletions(-)

diff --git a/board/amcc/canyonlands/canyonlands.c b/board/amcc/canyonlands/canyonlands.c
index 23874d2..c3c1348 100644
--- a/board/amcc/canyonlands/canyonlands.c
+++ b/board/amcc/canyonlands/canyonlands.c
@@ -34,7 +34,17 @@ extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH ch
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define CONFIG_SYS_BCSR3_PCIE		0x10
+	struct ep460c_bcsr {
+		u8	board_id;
+		u8	cpld_rev;
+		u8	led_user;
+		u8	board_status;
+		u8	reset_ctrl;
+		u8	flash_ctrl;
+		u8	eth_ctrl;
+		u8	usb_ctrl;
+		u8	irq_ctrl;
+};
 
 #define BOARD_CANYONLANDS_PCIE	1
 #define BOARD_CANYONLANDS_SATA	2
@@ -112,6 +122,9 @@ int board_early_init_f(void)
 {
 #if !defined(CONFIG_ARCHES)
 	u32 sdr0_cust0;
+	struct ep460c_bcsr *bcsr_data =
+		(struct ep460c_bcsr *)CONFIG_SYS_BCSR_BASE;
+
 #endif
 
 	/*
@@ -172,14 +185,10 @@ int board_early_init_f(void)
 
 #if !defined(CONFIG_ARCHES)
 	/* Enable ethernet and take out of reset */
-	out_8((void *)CONFIG_SYS_BCSR_BASE + 6, 0);
+	out_8(&bcsr_data->eth_ctrl, 0) ;
 
 	/* Remove NOR-FLASH, NAND-FLASH & EEPROM hardware write protection */
-	out_8((void *)CONFIG_SYS_BCSR_BASE + 5, 0);
-
-	/* Enable USB host & USB-OTG */
-	out_8((void *)CONFIG_SYS_BCSR_BASE + 7, 0);
-
+	out_8(&bcsr_data->flash_ctrl, 0) ;
 	mtsdr(SDR0_SRST1, 0);	/* Pull AHB out of reset default=1 */
 
 	/* Setup PLB4-AHB bridge based on the system address map */
@@ -201,6 +210,41 @@ int board_early_init_f(void)
 	return 0;
 }
 
+#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT)
+int usb_board_init(void)
+{
+	struct ep460c_bcsr *bcsr_data =
+		(struct ep460c_bcsr *)CONFIG_SYS_BCSR_BASE;
+	u8 val;
+
+	/* Enable USB host & USB-OTG */
+	val = in_8(&bcsr_data->usb_ctrl);
+	val &= ~(BCSR_USBCTRL_OTG_RST | BCSR_USBCTRL_HOST_RST);
+	out_8(&bcsr_data->usb_ctrl, val);
+
+	return 0;
+}
+
+int usb_board_stop(void)
+{
+	struct ep460c_bcsr *bcsr_data =
+		(struct ep460c_bcsr *)CONFIG_SYS_BCSR_BASE;
+	u8 val;
+
+	/* Disable USB host & USB-OTG */
+	val = in_8(&bcsr_data->usb_ctrl);
+	val |= (BCSR_USBCTRL_OTG_RST | BCSR_USBCTRL_HOST_RST);
+	out_8(&bcsr_data->usb_ctrl, val);
+
+	return 0;
+}
+
+int usb_board_init_fail(void)
+{
+	return usb_board_stop();
+}
+#endif /* CONFIG_USB_OHCI_NEW && CONFIG_SYS_USB_OHCI_BOARD_INIT */
+
 #if !defined(CONFIG_ARCHES)
 static void canyonlands_sata_init(int board_type)
 {
@@ -244,11 +288,13 @@ int get_cpu_num(void)
 #if !defined(CONFIG_ARCHES)
 int checkboard(void)
 {
+	struct ep460c_bcsr *bcsr_data =
+		(struct ep460c_bcsr *)CONFIG_SYS_BCSR_BASE;
 	char *s = getenv("serial#");
 
 	if (pvr_460ex()) {
 		printf("Board: Canyonlands - AMCC PPC460EX Evaluation Board");
-		if (in_8((void *)(CONFIG_SYS_BCSR_BASE + 3)) & CONFIG_SYS_BCSR3_PCIE)
+		if (in_8(&bcsr_data->board_status) & CONFIG_SYS_BCSR3_PCIE)
 			gd->board_type = BOARD_CANYONLANDS_PCIE;
 		else
 			gd->board_type = BOARD_CANYONLANDS_SATA;
@@ -268,7 +314,7 @@ int checkboard(void)
 		break;
 	}
 
-	printf(", Rev. %X", in_8((void *)(CONFIG_SYS_BCSR_BASE + 0)));
+	printf(", Rev. %X", in_8(&bcsr_data->cpld_rev));
 
 	if (s != NULL) {
 		puts(", serial# ");
diff --git a/include/configs/canyonlands.h b/include/configs/canyonlands.h
index ac9b3c5..0eee522 100644
--- a/include/configs/canyonlands.h
+++ b/include/configs/canyonlands.h
@@ -77,6 +77,18 @@
 #define CONFIG_SYS_PCIE0_XCFGBASE	0xc3000000
 #define CONFIG_SYS_PCIE1_XCFGBASE	0xc3001000
 
+/*
+ * BCSR bits as defined in the Canyonlands board user manual.
+ */
+#define BCSR_CPLDREV		0x00
+#define BCSR_BRDSTS		0x03
+#define BCSR_FLASHCTRL		0x05
+#define BCSR_ETHCTRL		0x06
+#define BCSR_USBCTRL		0x07
+#define BCSR_USBCTRL_OTG_RST	0x32
+#define BCSR_USBCTRL_HOST_RST	0x01
+#define CONFIG_SYS_BCSR3_PCIE	0x10
+
 #define	CONFIG_SYS_PCIE0_UTLBASE	0xc08010000ULL	/* 36bit physical addr	*/
 
 /* base address of inbound PCIe window */
@@ -417,6 +429,7 @@
 #define CONFIG_SYS_USB_OHCI_REGS_BASE	(CONFIG_SYS_AHB_BASE | 0xd0000)
 #define CONFIG_SYS_USB_OHCI_SLOT_NAME	"ppc440"
 #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 15
+#define CONFIG_SYS_USB_OHCI_BOARD_INIT
 #endif
 
 /*
-- 
1.5.6.3

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

* [U-Boot] [PATCH v2]ppc4xx/Canyonlands added USB board callbacks
  2010-07-07 10:49 [U-Boot] [PATCH v2]ppc4xx/Canyonlands added USB board callbacks Rupjyoti Sarmah
@ 2010-07-07 11:05 ` Stefan Roese
  2010-07-07 12:35   ` Rupjyoti Sarmah
  2010-07-07 11:13 ` Felix Radensky
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Roese @ 2010-07-07 11:05 UTC (permalink / raw)
  To: u-boot

Hi Rup,

On Wednesday 07 July 2010 12:49:06 Rupjyoti Sarmah wrote:
> Functions added to support board callbacks for USB init. This
> isolates USB manipulations such that it is only touched if USB is
> used by U-Boot.

Thanks. Looks quite good now. Please find a small comment below.
 
<snip>

> diff --git a/include/configs/canyonlands.h b/include/configs/canyonlands.h
> index ac9b3c5..0eee522 100644
> --- a/include/configs/canyonlands.h
> +++ b/include/configs/canyonlands.h
> @@ -77,6 +77,18 @@
>  #define CONFIG_SYS_PCIE0_XCFGBASE	0xc3000000
>  #define CONFIG_SYS_PCIE1_XCFGBASE	0xc3001000
> 
> +/*
> + * BCSR bits as defined in the Canyonlands board user manual.
> + */
> +#define BCSR_CPLDREV		0x00
> +#define BCSR_BRDSTS		0x03
> +#define BCSR_FLASHCTRL		0x05
> +#define BCSR_ETHCTRL		0x06
> +#define BCSR_USBCTRL		0x07
> +#define BCSR_USBCTRL_OTG_RST	0x32
> +#define BCSR_USBCTRL_HOST_RST	0x01
> +#define CONFIG_SYS_BCSR3_PCIE	0x10
> +

Hmmm. Which of these defines are really bits and which are offsets for 
registers? You can remove the register offsets defines, since you're using the 
struct now. And please use consistent naming, and don't name one bit 
"CONFIG_SYS_BCSRxxx".

Thanks.

Cheers,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de

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

* [U-Boot] [PATCH v2]ppc4xx/Canyonlands added USB board callbacks
  2010-07-07 10:49 [U-Boot] [PATCH v2]ppc4xx/Canyonlands added USB board callbacks Rupjyoti Sarmah
  2010-07-07 11:05 ` Stefan Roese
@ 2010-07-07 11:13 ` Felix Radensky
  1 sibling, 0 replies; 4+ messages in thread
From: Felix Radensky @ 2010-07-07 11:13 UTC (permalink / raw)
  To: u-boot

  Hi Rupjyoti,

On 7/7/2010 1:49 PM, Rupjyoti Sarmah wrote:
>
> -#define CONFIG_SYS_BCSR3_PCIE		0x10
> +	struct ep460c_bcsr {
> +		u8	board_id;
> +		u8	cpld_rev;
> +		u8	led_user;
> +		u8	board_status;
> +		u8	reset_ctrl;
> +		u8	flash_ctrl;
> +		u8	eth_ctrl;
> +		u8	usb_ctrl;
> +		u8	irq_ctrl;
> +};
>

Can you name this structure canyonlands_bcsr or just board_bcsr.
As Wolfgang said, ep460c is not not used anywhere in the code.

Thanks.

Felix.

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

* [U-Boot] [PATCH v2]ppc4xx/Canyonlands added USB board callbacks
  2010-07-07 11:05 ` Stefan Roese
@ 2010-07-07 12:35   ` Rupjyoti Sarmah
  0 siblings, 0 replies; 4+ messages in thread
From: Rupjyoti Sarmah @ 2010-07-07 12:35 UTC (permalink / raw)
  To: u-boot

Hi Stefan and Felix,

Thanks for your inputs. I am releasing v3 with the updates.

Regards,
Rup



-----Original Message-----
From: Stefan Roese [mailto:sr at denx.de]

> isolates USB manipulations such that it is only touched if USB is
> used by U-Boot.

Thanks. Looks quite good now. Please find a small comment below.

<snip>

> diff --git a/include/configs/canyonlands.h
b/include/configs/canyonlands.h
> index ac9b3c5..0eee522 100644
> --- a/include/configs/canyonlands.h
> +#define CONFIG_SYS_BCSR3_PCIE	0x10
> +

Hmmm. Which of these defines are really bits and which are offsets for
registers? You can remove the register offsets defines, since you're using
the
struct now. And please use consistent naming, and don't name one bit
"CONFIG_SYS_BCSRxxx".

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

end of thread, other threads:[~2010-07-07 12:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-07 10:49 [U-Boot] [PATCH v2]ppc4xx/Canyonlands added USB board callbacks Rupjyoti Sarmah
2010-07-07 11:05 ` Stefan Roese
2010-07-07 12:35   ` Rupjyoti Sarmah
2010-07-07 11:13 ` Felix Radensky

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