Skip to contentSkip to conversation

bmips: add support for bcm6348 usbh phy

PATCH New Álvaro Fernández Rojas 2 participants 8 messages Feb 4, 2018 – Mar 18, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover bmips: add support for bcm6348 usbh phy

Add support for BCM6348 usbh phy.

Álvaro Fernández Rojas (3):
phy: add support for bcm6348 usbh phy
mips: bmips: add support for bcm6348 usb
mips: bmips: add ct-5361 usb support

 arch/mips/dts/brcm,bcm6348.dtsi       | 20 ++++++++
 arch/mips/dts/comtrend,ct-5361.dts    |  8 +++
 configs/comtrend_ct5361_ram_defconfig |  7 +++
 drivers/phy/Kconfig                   |  6 +++
 drivers/phy/Makefile                  |  1 +
 drivers/phy/bcm6348-usbh-phy.c        | 94 +++++++++++++++++++++++++++++++++++
 include/configs/bmips_bcm6348.h       |  5 ++
 7 files changed, 141 insertions(+)
 create mode 100644 drivers/phy/bcm6348-usbh-phy.c
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/3 phy: add support for bcm6348 usbh phy

---
 drivers/phy/Kconfig            |  6 +++
 drivers/phy/Makefile           |  1 +
 drivers/phy/bcm6348-usbh-phy.c | 94 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+)
 create mode 100644 drivers/phy/bcm6348-usbh-phy.c
drivers/phy/Kconfig +6 -0
index 3b9a09ce18..cec2130c05 100644
@@ -59,6 +59,12 @@ config SPL_NOP_PHY
 	  This is useful when a driver uses the PHY framework but no real PHY
 	  hardware exists.
 
+config BCM6348_USBH_PHY
+	bool "BCM6348 USBH PHY support"
+	depends on PHY && ARCH_BMIPS
+	help
+	  Support for the Broadcom MIPS BCM6348 USBH PHY.
+
 config PIPE3_PHY
 	bool "Support omap's PIPE3 PHY"
 	depends on PHY && ARCH_OMAP2PLUS
drivers/phy/Makefile +1 -0
index 668040b0bb..06e01e86eb 100644
@@ -7,6 +7,7 @@
 
 obj-$(CONFIG_$(SPL_)PHY) += phy-uclass.o
 obj-$(CONFIG_$(SPL_)NOP_PHY) += nop-phy.o
+obj-$(CONFIG_BCM6348_USBH_PHY) += bcm6348-usbh-phy.o
 obj-$(CONFIG_PHY_SANDBOX) += sandbox-phy.o
 obj-$(CONFIG_$(SPL_)PIPE3_PHY) += ti-pipe3-phy.o
 obj-$(CONFIG_STI_USB_PHY) += sti_usb_phy.o
drivers/phy/bcm6348-usbh-phy.c new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
2.11.0
#2 lore raw

PATCH 1/3 phy: add support for bcm6348 usbh phy

Quoted 8 lines · Álvaro Fernández Rojas
---
 drivers/phy/Kconfig            |  6 +++
 drivers/phy/Makefile           |  1 +
 drivers/phy/bcm6348-usbh-phy.c | 94 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+)
 create mode 100644 drivers/phy/bcm6348-usbh-phy.c
Signature · 9 lines
- Daniel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180204/eb4f1030/attachment.sig>
#3 lore raw

PATCH 1/3 phy: add support for bcm6348 usbh phy

In reply to Álvaro Fernández Rojas
Quoted 89 lines · Álvaro Fernández Rojas
---
 drivers/phy/Kconfig            |  6 +++
 drivers/phy/Makefile           |  1 +
 drivers/phy/bcm6348-usbh-phy.c | 94 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+)
 create mode 100644 drivers/phy/bcm6348-usbh-phy.c
drivers/phy/Kconfig +6 -0
index 3b9a09ce18..cec2130c05 100644
@@ -59,6 +59,12 @@ config SPL_NOP_PHY
 	  This is useful when a driver uses the PHY framework but no real PHY
 	  hardware exists.
 
+config BCM6348_USBH_PHY
+	bool "BCM6348 USBH PHY support"
+	depends on PHY && ARCH_BMIPS
+	help
+	  Support for the Broadcom MIPS BCM6348 USBH PHY.
+
 config PIPE3_PHY
 	bool "Support omap's PIPE3 PHY"
 	depends on PHY && ARCH_OMAP2PLUS
drivers/phy/Makefile +1 -0
index 668040b0bb..06e01e86eb 100644
@@ -7,6 +7,7 @@
 
 obj-$(CONFIG_$(SPL_)PHY) += phy-uclass.o
 obj-$(CONFIG_$(SPL_)NOP_PHY) += nop-phy.o
+obj-$(CONFIG_BCM6348_USBH_PHY) += bcm6348-usbh-phy.o
 obj-$(CONFIG_PHY_SANDBOX) += sandbox-phy.o
 obj-$(CONFIG_$(SPL_)PIPE3_PHY) += ti-pipe3-phy.o
 obj-$(CONFIG_STI_USB_PHY) += sti_usb_phy.o
drivers/phy/bcm6348-usbh-phy.c new file +46 -0
new file mode 100644
index 0000000000..55e865c53d
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2018 Álvaro Fernández Rojas <[email protected]>
+ *
+ * Derived from linux/arch/mips/bcm63xx/usb-common.c:
+ *	Copyright 2008 Maxime Bizon <[email protected]>
+ *	Copyright 2013 Florian Fainelli <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <generic-phy.h>
+#include <reset.h>
+#include <asm/io.h>
+#include <dm/device.h>
+
+#define USBH_SETUP_PORT1_EN	BIT(0)
+
+struct bcm6348_usbh_priv {
+	void __iomem *regs;
+};
+
+static int bcm6348_usbh_init(struct phy *phy)
+{
+	struct bcm6348_usbh_priv *priv = dev_get_priv(phy->dev);
+
+	writel_be(USBH_SETUP_PORT1_EN, priv->regs);
+
+	return 0;
+}
+
+static struct phy_ops bcm6348_usbh_ops = {
+	.init = bcm6348_usbh_init,
+};
+
+static const struct udevice_id bcm6348_usbh_ids[] = {
+	{ .compatible = "brcm,bcm6348-usbh" },
+	{ /* sentinel */ }
+};
+
+static int bcm6348_usbh_probe(struct udevice *dev)
+{
+	struct bcm6348_usbh_priv *priv = dev_get_priv(dev);
+	struct reset_ctl rst_ctl;

drivers/phy/bcm6348-usbh-phy.c line 56

Quoted 10 lines
drivers/phy/bcm6348-usbh-phy.c new file +10 -0
+	struct clk clk;
+	fdt_addr_t addr;
+	fdt_size_t size;
+	int ret;
+
+	addr = devfdt_get_addr_size_index(dev, 0, &size);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	priv->regs = ioremap(addr, size);

since you started to convert the other BMIPS related drivers to live-tree, shall I pick up the current patches and you send a separate patch for the conversion later? Or do you want to resend a v2?

Quoted 39 lines
drivers/phy/bcm6348-usbh-phy.c new file +38 -0
+
+	/* enable usbh clock */
+	ret = clk_get_by_name(dev, "usbh", &clk);
+	if (ret < 0)
+		return ret;
+
+	ret = clk_enable(&clk);
+	if (ret < 0)
+		return ret;
+
+	ret = clk_free(&clk);
+	if (ret < 0)
+		return ret;
+
+	/* perform reset */
+	ret = reset_get_by_index(dev, 0, &rst_ctl);
+	if (ret < 0)
+		return ret;
+
+	ret = reset_deassert(&rst_ctl);
+	if (ret < 0)
+		return ret;
+
+	ret = reset_free(&rst_ctl);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+U_BOOT_DRIVER(bcm6348_usbh) = {
+	.name = "bcm6348-usbh",
+	.id = UCLASS_PHY,
+	.of_match = bcm6348_usbh_ids,
+	.ops = &bcm6348_usbh_ops,
+	.priv_auto_alloc_size = sizeof(struct bcm6348_usbh_priv),
+	.probe = bcm6348_usbh_probe,
+};
Signature · 9 lines
- Daniel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180317/8ee72e00/attachment.sig>
#4 lore raw

PATCH 1/3 phy: add support for bcm6348 usbh phy

Hi Daniel,

Quoted 96 lines · Daniel Schwierzeck
Quoted 94 lines · Álvaro Fernández Rojas
---
  drivers/phy/Kconfig            |  6 +++
  drivers/phy/Makefile           |  1 +
  drivers/phy/bcm6348-usbh-phy.c | 94 ++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 101 insertions(+)

create mode 100644 drivers/phy/bcm6348-usbh-phy.c

drivers/phy/Kconfig +6 -0
index 3b9a09ce18..cec2130c05 100644
@@ -59,6 +59,12 @@ config SPL_NOP_PHY
  	  This is useful when a driver uses the PHY framework but no real PHY
  	  hardware exists.
 
+config BCM6348_USBH_PHY
+	bool "BCM6348 USBH PHY support"
+	depends on PHY && ARCH_BMIPS
+	help
+	  Support for the Broadcom MIPS BCM6348 USBH PHY.
+
  config PIPE3_PHY
  	bool "Support omap's PIPE3 PHY"
  	depends on PHY && ARCH_OMAP2PLUS
drivers/phy/Makefile +1 -0
index 668040b0bb..06e01e86eb 100644
@@ -7,6 +7,7 @@
 
  obj-$(CONFIG_$(SPL_)PHY) += phy-uclass.o
  obj-$(CONFIG_$(SPL_)NOP_PHY) += nop-phy.o
+obj-$(CONFIG_BCM6348_USBH_PHY) += bcm6348-usbh-phy.o
  obj-$(CONFIG_PHY_SANDBOX) += sandbox-phy.o
  obj-$(CONFIG_$(SPL_)PIPE3_PHY) += ti-pipe3-phy.o
  obj-$(CONFIG_STI_USB_PHY) += sti_usb_phy.o
drivers/phy/bcm6348-usbh-phy.c new file +51 -0
new file mode 100644
index 0000000000..55e865c53d
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2018 Álvaro Fernández Rojas <[email protected]>
+ *
+ * Derived from linux/arch/mips/bcm63xx/usb-common.c:
+ *	Copyright 2008 Maxime Bizon <[email protected]>
+ *	Copyright 2013 Florian Fainelli <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <generic-phy.h>
+#include <reset.h>
+#include <asm/io.h>
+#include <dm/device.h>
+
+#define USBH_SETUP_PORT1_EN	BIT(0)
+
+struct bcm6348_usbh_priv {
+	void __iomem *regs;
+};
+
+static int bcm6348_usbh_init(struct phy *phy)
+{
+	struct bcm6348_usbh_priv *priv = dev_get_priv(phy->dev);
+
+	writel_be(USBH_SETUP_PORT1_EN, priv->regs);
+
+	return 0;
+}
+
+static struct phy_ops bcm6348_usbh_ops = {
+	.init = bcm6348_usbh_init,
+};
+
+static const struct udevice_id bcm6348_usbh_ids[] = {
+	{ .compatible = "brcm,bcm6348-usbh" },
+	{ /* sentinel */ }
+};
+
+static int bcm6348_usbh_probe(struct udevice *dev)
+{
+	struct bcm6348_usbh_priv *priv = dev_get_priv(dev);
+	struct reset_ctl rst_ctl;
+	struct clk clk;
+	fdt_addr_t addr;
+	fdt_size_t size;
+	int ret;
+
Quoted 8 lines

drivers/phy/bcm6348-usbh-phy.c line 56

Quoted 5 lines
drivers/phy/bcm6348-usbh-phy.c new file +5 -0
+	addr = devfdt_get_addr_size_index(dev, 0, &size);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	priv->regs = ioremap(addr, size);

since you started to convert the other BMIPS related drivers to live-tree, shall I pick up the current patches and you send a separate patch for the conversion later? Or do you want to resend a v2?

You can pick the current patches and I will send a conversion patch later :).

Quoted 40 lines
Quoted 40 lines
drivers/phy/bcm6348-usbh-phy.c new file +38 -0
+
+	/* enable usbh clock */
+	ret = clk_get_by_name(dev, "usbh", &clk);
+	if (ret < 0)
+		return ret;
+
+	ret = clk_enable(&clk);
+	if (ret < 0)
+		return ret;
+
+	ret = clk_free(&clk);
+	if (ret < 0)
+		return ret;
+
+	/* perform reset */
+	ret = reset_get_by_index(dev, 0, &rst_ctl);
+	if (ret < 0)
+		return ret;
+
+	ret = reset_deassert(&rst_ctl);
+	if (ret < 0)
+		return ret;
+
+	ret = reset_free(&rst_ctl);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+U_BOOT_DRIVER(bcm6348_usbh) = {
+	.name = "bcm6348-usbh",
+	.id = UCLASS_PHY,
+	.of_match = bcm6348_usbh_ids,
+	.ops = &bcm6348_usbh_ops,
+	.priv_auto_alloc_size = sizeof(struct bcm6348_usbh_priv),
+	.probe = bcm6348_usbh_probe,
+};
#5 lore raw

PATCH 2/3 mips: bmips: add support for bcm6348 usb

In reply to Álvaro Fernández Rojas
---
 arch/mips/dts/brcm,bcm6348.dtsi | 20 ++++++++++++++++++++
 include/configs/bmips_bcm6348.h |  5 +++++
 2 files changed, 25 insertions(+)
arch/mips/dts/brcm,bcm6348.dtsi +20 -0
index 540b9fea5b..92fb91afc1 100644
@@ -135,6 +135,26 @@
 			status = "disabled";
 		};
 
+		ohci: usb-controller at fffe1b00 {
+			compatible = "brcm,bcm6348-ohci", "generic-ohci";
+			reg = <0xfffe1b00 0x100>;
+			phys = <&usbh>;
+			big-endian;
+
+			status = "disabled";
+		};
+
+		usbh: usb-phy at fffe1c00 {
+			compatible = "brcm,bcm6348-usbh";
+			reg = <0xfffe1c00 0x4>;
+			#phy-cells = <0>;
+			clocks = <&periph_clk BCM6348_CLK_USBH>;
+			clock-names = "usbh";
+			resets = <&periph_rst BCM6348_RST_USBH>;
+
+			status = "disabled";
+		};
+
 		memory-controller at fffe2300 {
 			compatible = "brcm,bcm6338-mc";
 			reg = <0xfffe2300 0x38>;
include/configs/bmips_bcm6348.h +5 -0
index e9f53d6811..6c9c33b822 100644
@@ -14,6 +14,11 @@
 #define CONFIG_NR_DRAM_BANKS		1
 #define CONFIG_SYS_SDRAM_BASE		0x80000000
 
+/* USB */
+#define CONFIG_SYS_OHCI_SWAP_REG_ACCESS
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 2
+#define CONFIG_USB_OHCI_NEW
+
 /* U-Boot */
 #define CONFIG_SYS_LOAD_ADDR		CONFIG_SYS_SDRAM_BASE + 0x100000
 
Signature · 1 line
2.11.0
#6 lore raw

PATCH 3/3 mips: bmips: add ct-5361 usb support

In reply to Álvaro Fernández Rojas
---
 arch/mips/dts/comtrend,ct-5361.dts    | 8 ++++++++
 configs/comtrend_ct5361_ram_defconfig | 7 +++++++
 2 files changed, 15 insertions(+)
arch/mips/dts/comtrend,ct-5361.dts +8 -0
index c909a528a9..74dc09046c 100644
@@ -39,6 +39,10 @@
 	status = "okay";
 };
 
+&ohci {
+	status = "okay";
+};
+
 &pflash {
 	status = "okay";
 };
@@ -47,3 +51,7 @@
 	u-boot,dm-pre-reloc;
 	status = "okay";
 };
+
+&usbh {
+	status = "okay";
+};
configs/comtrend_ct5361_ram_defconfig +7 -0
index 1dfefcb379..8b842606f5 100644
@@ -25,6 +25,7 @@ CONFIG_CMD_LICENSE=y
 CONFIG_CMD_MEMINFO=y
 # CONFIG_CMD_FPGA is not set
 # CONFIG_CMD_LOADS is not set
+CONFIG_CMD_USB=y
 # CONFIG_CMD_NET is not set
 # CONFIG_CMD_NFS is not set
 # CONFIG_CMD_MISC is not set
@@ -37,9 +38,15 @@ CONFIG_LED_GPIO=y
 CONFIG_MTD=y
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_CFI_FLASH=y
+CONFIG_PHY=y
+CONFIG_BCM6348_USBH_PHY=y
 CONFIG_DM_RESET=y
 CONFIG_RESET_BCM6345=y
 # CONFIG_SPL_SERIAL_PRESENT is not set
 CONFIG_DM_SERIAL=y
 CONFIG_BCM6345_SERIAL=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_GENERIC=y
 CONFIG_WDT_BCM6345=y
Signature · 1 line
2.11.0
#7 lore raw

cover bmips: add support for bcm6348 usbh phy

In reply to Álvaro Fernández Rojas
Quoted 7 lines · Álvaro Fernández Rojas

Add support for BCM6348 usbh phy.

Álvaro Fernández Rojas (3):
phy: add support for bcm6348 usbh phy
mips: bmips: add support for bcm6348 usb
mips: bmips: add ct-5361 usb support

Quoted 10 lines
 arch/mips/dts/brcm,bcm6348.dtsi       | 20 ++++++++
 arch/mips/dts/comtrend,ct-5361.dts    |  8 +++
 configs/comtrend_ct5361_ram_defconfig |  7 +++
 drivers/phy/Kconfig                   |  6 +++
 drivers/phy/Makefile                  |  1 +
 drivers/phy/bcm6348-usbh-phy.c        | 94 +++++++++++++++++++++++++++++++++++
 include/configs/bmips_bcm6348.h       |  5 ++
 7 files changed, 141 insertions(+)
 create mode 100644 drivers/phy/bcm6348-usbh-phy.c

applied to u-boot-mips, thanks.

Signature · 9 lines
- Daniel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180319/34e42b71/attachment.sig>