From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 3/4] armv8/fsl-layerscape: add dwc3 gadget driver support
Date: Thu, 23 Jun 2016 16:57:18 +0200 [thread overview]
Message-ID: <20160623165718.05569eac@amdc2363> (raw)
In-Reply-To: <1465204596-6637-4-git-send-email-rajat.srivastava@nxp.com>
Hi Rajat,
> Implements the dwc3 gadget driver support for LS1043
> platform, and performs below operations:
> 1. Enables snooping support for DWC3 controller.
> 2. Enables cache coherency in LS1043 platform.
>
> Signed-off-by: Rajat Srivastava <rajat.srivastava@nxp.com>
> Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes in v2:
> - Moves DWC3 driver specific code to helper functions
> - Calls helper functions in SoC specific implementation
>
> arch/arm/cpu/armv8/fsl-layerscape/soc.c | 93
> ++++++++++++++++++++++ .../include/asm/arch-fsl-layerscape/immap_lsch2.h
> | 6 ++ 2 files changed, 99 insertions(+)
>
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
> b/arch/arm/cpu/armv8/fsl-layerscape/soc.c index 0fb5c7f..cc07524
> 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
> @@ -17,6 +17,10 @@
> #ifdef CONFIG_CHAIN_OF_TRUST
> #include <fsl_validate.h>
> #endif
> +#include <usb.h>
> +#include <dwc3-uboot.h>
> +#include <linux/usb/xhci-fsl.h>
> +
>
> DECLARE_GLOBAL_DATA_PTR;
>
> @@ -318,9 +322,18 @@ void fsl_lsch2_early_init_f(void)
> #if defined(CONFIG_FSL_QSPI) && !defined(CONFIG_QSPI_BOOT)
> out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
> #endif
> + /* Make SEC and USB reads and writes snoopable */
> +#if defined(CONFIG_LS1043A)
> + setbits_be32(&scfg->snpcnfgcr, SCFG_SNPCNFGCR_SECRDSNP |
> + SCFG_SNPCNFGCR_SECWRSNP |
> SCFG_SNPCNFGCR_USB1RDSNP |
> + SCFG_SNPCNFGCR_USB1WRSNP |
> SCFG_SNPCNFGCR_USB2RDSNP |
> + SCFG_SNPCNFGCR_USB2WRSNP |
> SCFG_SNPCNFGCR_USB3RDSNP |
> + SCFG_SNPCNFGCR_USB3WRSNP);
> +#else
> /* Make SEC reads and writes snoopable */
> setbits_be32(&scfg->snpcnfgcr, SCFG_SNPCNFGCR_SECRDSNP |
> SCFG_SNPCNFGCR_SECWRSNP);
> +#endif
>
> /*
> * Enable snoop requests and DVM message requests for
> @@ -336,6 +349,86 @@ void fsl_lsch2_early_init_f(void)
> }
> #endif
>
> +#ifdef CONFIG_USB_DWC3
> +
> +#if defined(CONFIG_LS1043A)
> +static struct dwc3_device dwc3_device_data0 = {
> + .maximum_speed = USB_SPEED_HIGH,
> + .base = CONFIG_SYS_FSL_XHCI_USB1_ADDR,
> + .dr_mode = USB_DR_MODE_PERIPHERAL,
> + .index = 0,
> +};
> +
> +static struct dwc3_device dwc3_device_data1 = {
> + .maximum_speed = USB_SPEED_HIGH,
> + .base = CONFIG_SYS_FSL_XHCI_USB2_ADDR,
> + .dr_mode = USB_DR_MODE_PERIPHERAL,
> + .index = 1,
> +};
> +
> +static struct dwc3_device dwc3_device_data2 = {
> + .maximum_speed = USB_SPEED_HIGH,
> + .base = CONFIG_SYS_FSL_XHCI_USB3_ADDR,
> + .dr_mode = USB_DR_MODE_PERIPHERAL,
> + .index = 2,
> +};
> +
> +int usb_gadget_handle_interrupts(int index)
> +{
> + dwc3_uboot_handle_interrupt(index);
> + return 0;
> +}
> +#endif
> +
> +int board_usb_init(int index, enum usb_init_type init)
Are those usb related functions generic? To ask in another way, would
it be possible to reuse those functions for other armv8 boards?
Please correct me if I'm wrong, but it seems that LS1043 is a single
board. Maybe it would be better to place this code in a
separate ./board/nxp/ls1043 directory?
> +{
> + switch (init) {
> + case USB_INIT_DEVICE:
> + switch (index) {
> +#if defined(CONFIG_LS1043A)
> + case 0:
> + dwc3_uboot_init(&dwc3_device_data0);
> + break;
> + case 1:
> + dwc3_uboot_init(&dwc3_device_data1);
> + break;
> + case 2:
> + dwc3_uboot_init(&dwc3_device_data2);
> + break;
> +#endif
> + default:
> + printf("Invalid Controller Index\n");
> + return -1;
> + }
> +#if defined(CONFIG_LS1043A)
> + dwc3_core_incr_burst_enable(index, 0xf, 0xf);
> + dwc3_core_set_snooping(index, true);
> +#endif
> + break;
> + default:
> + break;
> + }
> +
> + return 0;
> +}
> +
> +int board_usb_cleanup(int index, enum usb_init_type init)
> +{
> + switch (init) {
> + case USB_INIT_DEVICE:
> +#if defined(CONFIG_LS1043A)
> + dwc3_uboot_exit(index);
> +#endif
> + break;
> + default:
> + break;
> + }
> + return 0;
> +}
> +#endif
> +
> +
> +
> #ifdef CONFIG_BOARD_LATE_INIT
> int board_late_init(void)
> {
> diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
> b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h index
> 57b99d4..13ba1a6 100644 ---
> a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h +++
> b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h @@ -328,6
> +328,12 @@ struct ccsr_gur {
> #define SCFG_SNPCNFGCR_SECRDSNP 0x80000000
> #define SCFG_SNPCNFGCR_SECWRSNP 0x40000000
> +#define SCFG_SNPCNFGCR_USB1RDSNP 0x00200000
> +#define SCFG_SNPCNFGCR_USB1WRSNP 0x00100000
> +#define SCFG_SNPCNFGCR_USB2RDSNP 0x00008000
> +#define SCFG_SNPCNFGCR_USB2WRSNP 0x00010000
> +#define SCFG_SNPCNFGCR_USB3RDSNP 0x00002000
> +#define SCFG_SNPCNFGCR_USB3WRSNP 0x00004000
>
> /* Supplemental Configuration Unit */
> struct ccsr_scfg {
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
next prev parent reply other threads:[~2016-06-23 14:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 9:16 [U-Boot] [PATCH v2 0/4] armv8/fsl-layerscape: add dwc3 gadget driver support Rajat Srivastava
2016-06-06 9:16 ` [U-Boot] [PATCH v2 1/4] usb: ums: support multiple controllers using controller_index Rajat Srivastava
2016-06-23 14:44 ` Lukasz Majewski
2016-06-06 9:16 ` [U-Boot] [PATCH v2 2/4] usb: dwc3: Add helper functions to enable snooping and burst settings Rajat Srivastava
2016-06-06 12:54 ` Marek Vasut
2016-06-08 9:44 ` Rajesh Bhagat
2016-06-08 13:26 ` Marek Vasut
2016-06-10 0:34 ` Simon Glass
2016-06-14 4:09 ` Rajesh Bhagat
2016-06-17 3:51 ` Simon Glass
2016-07-04 4:33 ` Rajesh Bhagat
2016-06-23 14:53 ` Lukasz Majewski
2016-07-04 4:37 ` Rajesh Bhagat
2016-07-27 17:00 ` york sun
2016-06-06 9:16 ` [U-Boot] [PATCH v2 3/4] armv8/fsl-layerscape: add dwc3 gadget driver support Rajat Srivastava
2016-06-10 0:35 ` Simon Glass
2016-06-14 4:11 ` Rajesh Bhagat
2016-06-23 14:57 ` Lukasz Majewski [this message]
2016-07-04 4:37 ` Rajesh Bhagat
2016-07-04 7:18 ` Lukasz Majewski
2016-06-06 9:16 ` [U-Boot] [PATCH v2 4/4] armv8/fsl-layerscape: enable " Rajat Srivastava
2016-06-23 14:57 ` Lukasz Majewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160623165718.05569eac@amdc2363 \
--to=l.majewski@samsung.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox