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

Commit aec2927b authored by Chris Brandt's avatar Chris Brandt Committed by Greg Kroah-Hartman
Browse files

usb: renesas_usbhs: Add support for RZ/A1



This patch adds the capability to support RZ/A1 SoCs.

Signed-off-by: default avatarChris Brandt <chris.brandt@renesas.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ce5bf9a5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@

obj-$(CONFIG_USB_RENESAS_USBHS)	+= renesas_usbhs.o

renesas_usbhs-y			:= common.o mod.o pipe.o fifo.o rcar2.o rcar3.o
renesas_usbhs-y			:= common.o mod.o pipe.o fifo.o rcar2.o rcar3.o rza.o

ifneq ($(CONFIG_USB_RENESAS_USBHS_HCD),)
	renesas_usbhs-y		+= mod_host.o
+13 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include "common.h"
#include "rcar2.h"
#include "rcar3.h"
#include "rza.h"

/*
 *		image of renesas_usbhs
@@ -488,6 +489,10 @@ static const struct of_device_id usbhs_of_match[] = {
		.compatible = "renesas,rcar-gen3-usbhs",
		.data = (void *)USBHS_TYPE_RCAR_GEN3,
	},
	{
		.compatible = "renesas,rza1-usbhs",
		.data = (void *)USBHS_TYPE_RZA1,
	},
	{ },
};
MODULE_DEVICE_TABLE(of, usbhs_of_match);
@@ -520,6 +525,11 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
		dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
	}

	if (dparam->type == USBHS_TYPE_RZA1) {
		dparam->pipe_configs = usbhsc_new_pipe;
		dparam->pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
	}

	return info;
}

@@ -591,6 +601,9 @@ static int usbhs_probe(struct platform_device *pdev)
				dev_err(&pdev->dev, "no notifier registered\n");
		}
		break;
	case USBHS_TYPE_RZA1:
		priv->pfunc = usbhs_rza1_ops;
		break;
	default:
		if (!info->platform_callback.get_id) {
			dev_err(&pdev->dev, "no platform callbacks");
+6 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ struct usbhs_priv;
#define D2FIFOCTR	0x00F2	/* for R-Car Gen2 */
#define D3FIFOSEL	0x00F4	/* for R-Car Gen2 */
#define D3FIFOCTR	0x00F6	/* for R-Car Gen2 */
#define SUSPMODE	0x0102	/* for RZ/A */

/* SYSCFG */
#define SCKE	(1 << 10)	/* USB Module Clock Enable */
@@ -106,6 +107,8 @@ struct usbhs_priv;
#define DRPD	(1 << 5)	/* D+ Line/D- Line Resistance Control */
#define DPRPU	(1 << 4)	/* D+ Line Resistance Control */
#define USBE	(1 << 0)	/* USB Module Operation Enable */
#define UCKSEL	(1 << 2)	/* Clock Select for RZ/A1 */
#define UPLLE	(1 << 1)	/* USB PLL Enable for RZ/A1 */

/* DVSTCTR */
#define EXTLP	(1 << 10)	/* Controls the EXTLP pin output state */
@@ -233,6 +236,9 @@ struct usbhs_priv;
#define USBSPD_SPEED_FULL	0x2
#define USBSPD_SPEED_HIGH	0x3

/* SUSPMODE */
#define SUSPM		(1 << 14)	/* SuspendM Control */

/*
 *		struct
 */
+52 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Renesas USB driver RZ/A initialization and power control
 *
 * Copyright (C) 2018 Chris Brandt
 * Copyright (C) 2018 Renesas Electronics Corporation
 */

#include <linux/delay.h>
#include <linux/io.h>
#include <linux/of_device.h>
#include "common.h"
#include "rza.h"

static int usbhs_rza1_hardware_init(struct platform_device *pdev)
{
	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
	struct device_node *usb_x1_clk, *extal_clk;
	u32 freq_usb = 0, freq_extal = 0;

	/* Input Clock Selection (NOTE: ch0 controls both ch0 and ch1) */
	usb_x1_clk = of_find_node_by_name(NULL, "usb_x1");
	extal_clk = of_find_node_by_name(NULL, "extal");
	of_property_read_u32(usb_x1_clk, "clock-frequency", &freq_usb);
	of_property_read_u32(extal_clk, "clock-frequency", &freq_extal);
	if (freq_usb == 0) {
		if (freq_extal == 12000000) {
			/* Select 12MHz XTAL */
			usbhs_bset(priv, SYSCFG, UCKSEL, UCKSEL);
		} else {
			dev_err(usbhs_priv_to_dev(priv), "A 48MHz USB clock or 12MHz main clock is required.\n");
			return -EIO;
		}
	}

	/* Enable USB PLL (NOTE: ch0 controls both ch0 and ch1) */
	usbhs_bset(priv, SYSCFG, UPLLE, UPLLE);
	udelay(1000);
	usbhs_bset(priv, SUSPMODE, SUSPM, SUSPM);

	return 0;
}

static int usbhs_rza_get_id(struct platform_device *pdev)
{
	return USBHS_GADGET;
}

const struct renesas_usbhs_platform_callback usbhs_rza1_ops = {
	.hardware_init = usbhs_rza1_hardware_init,
	.get_id = usbhs_rza_get_id,
};
+4 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
#include "common.h"

extern const struct renesas_usbhs_platform_callback usbhs_rza1_ops;
Loading