Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 48f6b099 authored by Sascha Hauer's avatar Sascha Hauer
Browse files

ARM i.MX: introduce imx_otg_ulpi_create to create ULPI transceivers



The boards are currently using otg_ulpi_create and mxc_ulpi_access_ops,
both are only present if CONFIG_USB_ULPI is set. To remove the need of
ifdefs in the board code introduce a imx_otg_ulpi_create functions
which expands to a static inline function if compiled without ulpi.

Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
parent 94573e66
Loading
Loading
Loading
Loading
+10 −14
Original line number Original line Diff line number Diff line
@@ -209,7 +209,6 @@ static struct platform_device serial_device = {
};
};
#endif
#endif


#if defined(CONFIG_USB_ULPI)
static int eukrea_cpuimx27_otg_init(struct platform_device *pdev)
static int eukrea_cpuimx27_otg_init(struct platform_device *pdev)
{
{
	return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
	return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
@@ -229,7 +228,6 @@ static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
	.init	= eukrea_cpuimx27_usbh2_init,
	.init	= eukrea_cpuimx27_usbh2_init,
	.portsc	= MXC_EHCI_MODE_ULPI,
	.portsc	= MXC_EHCI_MODE_ULPI,
};
};
#endif


static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
	.operating_mode = FSL_USB2_DR_DEVICE,
	.operating_mode = FSL_USB2_DR_DEVICE,
@@ -283,21 +281,19 @@ static void __init eukrea_cpuimx27_init(void)
	platform_device_register(&serial_device);
	platform_device_register(&serial_device);
#endif
#endif


#if defined(CONFIG_USB_ULPI)
	if (otg_mode_host) {
	if (otg_mode_host) {
		otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
		otg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
				ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
				ULPI_OTG_DRVVBUS_EXT);

		if (otg_pdata.otg)
			imx27_add_mxc_ehci_otg(&otg_pdata);
			imx27_add_mxc_ehci_otg(&otg_pdata);
	} else {
		imx27_add_fsl_usb2_udc(&otg_device_pdata);
	}
	}


	usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
	usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
				ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
			ULPI_OTG_DRVVBUS_EXT);

	if (usbh2_pdata.otg)
		imx27_add_mxc_ehci_hs(2, &usbh2_pdata);
		imx27_add_mxc_ehci_hs(2, &usbh2_pdata);
#endif
	if (!otg_mode_host)
		imx27_add_fsl_usb2_udc(&otg_device_pdata);


#ifdef CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD
#ifdef CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD
	eukrea_mbimx27_baseboard_init();
	eukrea_mbimx27_baseboard_init();
+6 −7
Original line number Original line Diff line number Diff line
@@ -162,7 +162,6 @@ static int otg_phy_init(void)
	return 0;
	return 0;
}
}


#if defined(CONFIG_USB_ULPI)
static int mx27_3ds_otg_init(struct platform_device *pdev)
static int mx27_3ds_otg_init(struct platform_device *pdev)
{
{
	return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
	return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI);
@@ -172,7 +171,6 @@ static struct mxc_usbh_platform_data otg_pdata __initdata = {
	.init	= mx27_3ds_otg_init,
	.init	= mx27_3ds_otg_init,
	.portsc	= MXC_EHCI_MODE_ULPI,
	.portsc	= MXC_EHCI_MODE_ULPI,
};
};
#endif


static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
	.operating_mode = FSL_USB2_DR_DEVICE,
	.operating_mode = FSL_USB2_DR_DEVICE,
@@ -275,14 +273,15 @@ static void __init mx27pdk_init(void)
	imx27_add_mxc_mmc(0, &sdhc1_pdata);
	imx27_add_mxc_mmc(0, &sdhc1_pdata);
	imx27_add_imx2_wdt(NULL);
	imx27_add_imx2_wdt(NULL);
	otg_phy_init();
	otg_phy_init();
#if defined(CONFIG_USB_ULPI)

	if (otg_mode_host) {
	if (otg_mode_host) {
		otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
		otg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
				ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
				ULPI_OTG_DRVVBUS_EXT);


		if (otg_pdata.otg)
			imx27_add_mxc_ehci_otg(&otg_pdata);
			imx27_add_mxc_ehci_otg(&otg_pdata);
	}
	}
#endif

	if (!otg_mode_host)
	if (!otg_mode_host)
		imx27_add_fsl_usb2_udc(&otg_device_pdata);
		imx27_add_fsl_usb2_udc(&otg_device_pdata);


+9 −12
Original line number Original line Diff line number Diff line
@@ -267,7 +267,6 @@ static const struct imxmmc_platform_data sdhc_pdata __initconst = {
	.exit = pca100_sdhc2_exit,
	.exit = pca100_sdhc2_exit,
};
};


#if defined(CONFIG_USB_ULPI)
static int otg_phy_init(struct platform_device *pdev)
static int otg_phy_init(struct platform_device *pdev)
{
{
	gpio_set_value(OTG_PHY_CS_GPIO, 0);
	gpio_set_value(OTG_PHY_CS_GPIO, 0);
@@ -295,7 +294,6 @@ static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
	.init	= usbh2_phy_init,
	.init	= usbh2_phy_init,
	.portsc	= MXC_EHCI_MODE_ULPI,
	.portsc	= MXC_EHCI_MODE_ULPI,
};
};
#endif


static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
	.operating_mode = FSL_USB2_DR_DEVICE,
	.operating_mode = FSL_USB2_DR_DEVICE,
@@ -402,23 +400,22 @@ static void __init pca100_init(void)
	gpio_request(USBH2_PHY_CS_GPIO, "usb-host2-cs");
	gpio_request(USBH2_PHY_CS_GPIO, "usb-host2-cs");
	gpio_direction_output(USBH2_PHY_CS_GPIO, 1);
	gpio_direction_output(USBH2_PHY_CS_GPIO, 1);


#if defined(CONFIG_USB_ULPI)
	if (otg_mode_host) {
	if (otg_mode_host) {
		otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
		otg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
				ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
				ULPI_OTG_DRVVBUS_EXT);


		if (otg_pdata.otg)
			imx27_add_mxc_ehci_otg(&otg_pdata);
			imx27_add_mxc_ehci_otg(&otg_pdata);
	} else {
		gpio_set_value(OTG_PHY_CS_GPIO, 0);
		imx27_add_fsl_usb2_udc(&otg_device_pdata);
	}
	}


	usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
	usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
				ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
				ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);


	if (usbh2_pdata.otg)
		imx27_add_mxc_ehci_hs(2, &usbh2_pdata);
		imx27_add_mxc_ehci_hs(2, &usbh2_pdata);
#endif
	if (!otg_mode_host) {
		gpio_set_value(OTG_PHY_CS_GPIO, 0);
		imx27_add_fsl_usb2_udc(&otg_device_pdata);
	}


	imx27_add_imx_fb(&pca100_fb_data);
	imx27_add_imx_fb(&pca100_fb_data);


+9 −11
Original line number Original line Diff line number Diff line
@@ -133,7 +133,6 @@ static int armadillo5x0_pins[] = {
};
};


/* USB */
/* USB */
#if defined(CONFIG_USB_ULPI)


#define OTG_RESET IOMUX_TO_GPIO(MX31_PIN_STXD4)
#define OTG_RESET IOMUX_TO_GPIO(MX31_PIN_STXD4)
#define USBH2_RESET IOMUX_TO_GPIO(MX31_PIN_SCK6)
#define USBH2_RESET IOMUX_TO_GPIO(MX31_PIN_SCK6)
@@ -256,7 +255,6 @@ static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
	.init	= usbh2_init,
	.init	= usbh2_init,
	.portsc	= MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
	.portsc	= MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
};
};
#endif /* CONFIG_USB_ULPI */


/* RTC over I2C*/
/* RTC over I2C*/
#define ARMADILLO5X0_RTC_GPIO	IOMUX_TO_GPIO(MX31_PIN_SRXD4)
#define ARMADILLO5X0_RTC_GPIO	IOMUX_TO_GPIO(MX31_PIN_SRXD4)
@@ -549,15 +547,15 @@ static void __init armadillo5x0_init(void)
	i2c_register_board_info(1, &armadillo5x0_i2c_rtc, 1);
	i2c_register_board_info(1, &armadillo5x0_i2c_rtc, 1);


	/* USB */
	/* USB */
#if defined(CONFIG_USB_ULPI)
	usbotg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
			ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
	usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
			ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);


	usbotg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
			ULPI_OTG_DRVVBUS_EXT);
	if (usbotg_pdata.otg)
		imx31_add_mxc_ehci_otg(&usbotg_pdata);
		imx31_add_mxc_ehci_otg(&usbotg_pdata);
	usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
			ULPI_OTG_DRVVBUS_EXT);
	if (usbh2_pdata.otg)
		imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
		imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
#endif
}
}


static void __init armadillo5x0_timer_init(void)
static void __init armadillo5x0_timer_init(void)
+9 −11
Original line number Original line Diff line number Diff line
@@ -244,7 +244,6 @@ static int mx31_3ds_usbotg_init(void)
	return err;
	return err;
}
}


#if defined(CONFIG_USB_ULPI)
static int mx31_3ds_otg_init(struct platform_device *pdev)
static int mx31_3ds_otg_init(struct platform_device *pdev)
{
{
	return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
	return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
@@ -300,7 +299,6 @@ static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
	.init = mx31_3ds_host2_init,
	.init = mx31_3ds_host2_init,
	.portsc	= MXC_EHCI_MODE_ULPI,
	.portsc	= MXC_EHCI_MODE_ULPI,
};
};
#endif


static const struct fsl_usb2_platform_data usbotg_pdata __initconst = {
static const struct fsl_usb2_platform_data usbotg_pdata __initconst = {
	.operating_mode = FSL_USB2_DR_DEVICE,
	.operating_mode = FSL_USB2_DR_DEVICE,
@@ -345,17 +343,17 @@ static void __init mx31_3ds_init(void)
	imx31_add_imx_keypad(&mx31_3ds_keymap_data);
	imx31_add_imx_keypad(&mx31_3ds_keymap_data);


	mx31_3ds_usbotg_init();
	mx31_3ds_usbotg_init();
#if defined(CONFIG_USB_ULPI)
	if (otg_mode_host) {
	if (otg_mode_host) {
		otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
		otg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
				ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
				ULPI_OTG_DRVVBUS_EXT);

		if (otg_pdata.otg)
			imx31_add_mxc_ehci_otg(&otg_pdata);
			imx31_add_mxc_ehci_otg(&otg_pdata);
	}
	}
	usbh2_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
	usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
				ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
			ULPI_OTG_DRVVBUS_EXT);
	if (usbh2_pdata.otg)
		imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
		imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
#endif

	if (!otg_mode_host)
	if (!otg_mode_host)
		imx31_add_fsl_usb2_udc(&usbotg_pdata);
		imx31_add_fsl_usb2_udc(&usbotg_pdata);


Loading