Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1693738 > unrolled thread
| Started by | Al Cooper <alcooperx@gmail.com> |
|---|---|
| First post | 2017-07-21 16:20 +0200 |
| Last post | 2017-07-22 19:10 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v4 0/4] Add Broadcom STB USB phy driver Al Cooper <alcooperx@gmail.com> - 2017-07-21 16:20 +0200
[PATCH v4 4/4] phy: usb: phy-brcm-usb: Add ability to force DRD mode to host or device Al Cooper <alcooperx@gmail.com> - 2017-07-21 16:20 +0200
[PATCH v4 1/4] soc: brcmstb: Add Product ID and Family ID helper functions Al Cooper <alcooperx@gmail.com> - 2017-07-21 16:20 +0200
Re: [PATCH v4 1/4] soc: brcmstb: Add Product ID and Family ID helper functions Florian Fainelli <f.fainelli@gmail.com> - 2017-07-22 19:10 +0200
| From | Al Cooper <alcooperx@gmail.com> |
|---|---|
| Date | 2017-07-21 16:20 +0200 |
| Subject | [PATCH v4 0/4] Add Broadcom STB USB phy driver |
| Message-ID | <u5GWC-5Tl-19@gated-at.bofh.it> |
Add a new USB Phy driver for Broadcom STB SoCs. This driver
supports Broadcom STB ARM SoCs. This driver in
combination with the Broadcom STB ohci, ehci and xhci
drivers will enable USB1.1, USB2.0 and USB3.0 support.
This Phy driver also supports the Broadcom BDC gadget
driver.
Changes since v3:
- Removed MIPS support because there is such a small
amount of code that is common to both ARM and MIPS.
I'll create a separate MIPS driver in the future.
- Have the Kconfig selection for this driver also select
"CONFIG_SOC_BRCMSTB" which contains needed functions.
- Change device tree properties to use "brcm,has_xhci" and
"brcm,has_eohci" to determine if the phy contains
a xhci phy, and e/ohci phy or both.
- Change the phy xlate routine to return an error instead
of NULL for a requested phy that doesn't exist.
- Moved some probe functionality into it's own funtion to
simplify the many "if (has_xhci)" statements.
Changes since v2:
- Fix kbuild errors by changing Kconfig so the driver
only builds for ARCH_BRCMSTB || BMIPS_GENERIC systems
Changes since v1:
- Rebased to next
- Add Kconfig entry to build the driver
- Commented all delays
- Split out sysfs functionality in separate patch
- Removed parsing of old obselete device tree properties
- Changed device property "device" to "dr_mode" using
standard values "host" and "peripheral" along with new
values "drd" and "typec-pd"
- Add ability to handle the standard PHY_TYPE_USB2 and
PHY_TYPE_USB3 arguments passed in by phy consumers.
- Moved phy_provider_register() to end of probe routine
Al Cooper (4):
soc: brcmstb: Add Product ID and Family ID helper functions
dt-bindings: Add Broadcom STB USB PHY binding document
phy: usb: phy-brcm-usb: Add Broadcom STB USB phy driver
phy: usb: phy-brcm-usb: Add ability to force DRD mode to host or
device
.../bindings/phy/brcm,brcmstb-usb-phy.txt | 43 +
MAINTAINERS | 7 +
drivers/phy/broadcom/Kconfig | 13 +
drivers/phy/broadcom/Makefile | 3 +
drivers/phy/broadcom/phy-brcm-usb-init.c | 1034 ++++++++++++++++++++
drivers/phy/broadcom/phy-brcm-usb-init.h | 50 +
drivers/phy/broadcom/phy-brcm-usb.c | 460 +++++++++
drivers/soc/bcm/brcmstb/common.c | 12 +
include/linux/soc/brcmstb/brcmstb.h | 10 +
9 files changed, 1632 insertions(+)
create mode 100644 Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
create mode 100644 drivers/phy/broadcom/phy-brcm-usb-init.c
create mode 100644 drivers/phy/broadcom/phy-brcm-usb-init.h
create mode 100644 drivers/phy/broadcom/phy-brcm-usb.c
--
1.9.0.138.g2de3478
[toc] | [next] | [standalone]
| From | Al Cooper <alcooperx@gmail.com> |
|---|---|
| Date | 2017-07-21 16:20 +0200 |
| Subject | [PATCH v4 4/4] phy: usb: phy-brcm-usb: Add ability to force DRD mode to host or device |
| Message-ID | <u5GWD-5Tl-53@gated-at.bofh.it> |
| In reply to | #1693738 |
From: Al Cooper <al.cooper@broadcom.com>
When the usb phy device mode is set to "drd", the USB port will
switch between device and host modes depending on what's plugged
into the port. Customers have asked for the ability to force
host or device mode from software. This commit adds sysfs
entries to the phy device that allow this. The sysfs for the phy
device can be found at:
/sys/bus/platform/drivers/brcmstb-usb-phy/*.usb-phy
The following sysfs entries were added:
- "dr_mode" (RO) - The current phy "dr_mode" setting.
It will be set to one of the following values:
- "host" - host mode
- "peripheral " - device mode
- "drd" - switch between device and host mode based on
installed device
- "typec-pd" - device/host mode is controller by the USB
Type-C PD protocol.
If "dr_mode" is "drd"
- "drd_select" (RW) -
It will be set to one of the following values:
- "host" - force host mode
- "device" - force device mode
- "auto" - allow normal auto selection of host/device based on
inserted USB device
Signed-off-by: Al Cooper <alcooperx@gmail.com>
---
drivers/phy/broadcom/phy-brcm-usb.c | 85 +++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c
index 429ef1c..27f47a3 100644
--- a/drivers/phy/broadcom/phy-brcm-usb.c
+++ b/drivers/phy/broadcom/phy-brcm-usb.c
@@ -27,6 +27,8 @@
#include "phy-brcm-usb-init.h"
+static DEFINE_MUTEX(sysfs_lock);
+
enum brcm_usb_phy_id {
BRCM_USB_PHY_2_0 = 0,
BRCM_USB_PHY_3_0,
@@ -45,6 +47,12 @@ struct value_to_name_map {
{ USB_CTLR_MODE_TYPEC_PD, "typec-pd" }
};
+static struct value_to_name_map brcm_dual_mode_to_name[] = {
+ { 0, "host" },
+ { 1, "device" },
+ { 2, "auto" },
+};
+
struct brcm_usb_phy {
struct phy *phy;
unsigned int id;
@@ -162,6 +170,73 @@ static int name_to_value(struct value_to_name_map *table, int count,
return -EINVAL;
}
+static const char *value_to_name(struct value_to_name_map *table, int count,
+ int value)
+{
+ if (value >= count)
+ return "unknown";
+ return table[value].name;
+}
+
+static ssize_t dr_mode_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
+
+ return sprintf(buf, "%s\n",
+ value_to_name(&brcm_dr_mode_to_name[0],
+ ARRAY_SIZE(brcm_dr_mode_to_name),
+ priv->ini.mode));
+}
+static DEVICE_ATTR_RO(dr_mode);
+
+static ssize_t dual_select_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
+ int value;
+ int res;
+
+ mutex_lock(&sysfs_lock);
+ res = name_to_value(&brcm_dual_mode_to_name[0],
+ ARRAY_SIZE(brcm_dual_mode_to_name), buf, &value);
+ if (!res) {
+ brcm_usb_init_set_dual_select(&priv->ini, value);
+ res = len;
+ }
+ mutex_unlock(&sysfs_lock);
+ return res;
+}
+
+static ssize_t dual_select_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
+ int value;
+
+ mutex_lock(&sysfs_lock);
+ value = brcm_usb_init_get_dual_select(&priv->ini);
+ mutex_unlock(&sysfs_lock);
+ return sprintf(buf, "%s\n",
+ value_to_name(&brcm_dual_mode_to_name[0],
+ ARRAY_SIZE(brcm_dual_mode_to_name),
+ value));
+}
+static DEVICE_ATTR_RW(dual_select);
+
+static struct attribute *brcm_usb_phy_attrs[] = {
+ &dev_attr_dr_mode.attr,
+ &dev_attr_dual_select.attr,
+ NULL
+};
+
+static const struct attribute_group brcm_usb_phy_group = {
+ .attrs = brcm_usb_phy_attrs,
+};
+
static int brcm_usb_phy_dvr_init(struct device *dev,
struct brcm_usb_phy_data *priv,
struct device_node *dn)
@@ -278,6 +353,16 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
/* make sure invert settings are correct */
brcm_usb_init_ipp(&priv->ini);
+ /*
+ * Create sysfs entries for mode.
+ * Remove "dual_select" attribute if not in dual mode
+ */
+ if (priv->ini.mode != USB_CTLR_MODE_DRD)
+ brcm_usb_phy_attrs[1] = NULL;
+ err = sysfs_create_group(&dev->kobj, &brcm_usb_phy_group);
+ if (err)
+ dev_warn(dev, "Error creating sysfs attributes\n");
+
/* start with everything off */
if (priv->has_xhci)
brcm_usb_uninit_xhci(&priv->ini);
--
1.9.0.138.g2de3478
[toc] | [prev] | [next] | [standalone]
| From | Al Cooper <alcooperx@gmail.com> |
|---|---|
| Date | 2017-07-21 16:20 +0200 |
| Subject | [PATCH v4 1/4] soc: brcmstb: Add Product ID and Family ID helper functions |
| Message-ID | <u5GWD-5Tl-55@gated-at.bofh.it> |
| In reply to | #1693738 |
Signed-off-by: Al Cooper <alcooperx@gmail.com>
---
drivers/soc/bcm/brcmstb/common.c | 12 ++++++++++++
include/linux/soc/brcmstb/brcmstb.h | 10 ++++++++++
2 files changed, 22 insertions(+)
diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c
index b6195fd..184dbf5 100644
--- a/drivers/soc/bcm/brcmstb/common.c
+++ b/drivers/soc/bcm/brcmstb/common.c
@@ -40,6 +40,18 @@ bool soc_is_brcmstb(void)
return of_match_node(brcmstb_machine_match, root) != NULL;
}
+u32 brcmstb_get_family_id(void)
+{
+ return family_id;
+}
+EXPORT_SYMBOL(brcmstb_get_family_id);
+
+u32 brcmstb_get_product_id(void)
+{
+ return product_id;
+}
+EXPORT_SYMBOL(brcmstb_get_product_id);
+
static const struct of_device_id sun_top_ctrl_match[] = {
{ .compatible = "brcm,bcm7125-sun-top-ctrl", },
{ .compatible = "brcm,bcm7346-sun-top-ctrl", },
diff --git a/include/linux/soc/brcmstb/brcmstb.h b/include/linux/soc/brcmstb/brcmstb.h
index 337ce41..23e4dc9 100644
--- a/include/linux/soc/brcmstb/brcmstb.h
+++ b/include/linux/soc/brcmstb/brcmstb.h
@@ -1,10 +1,20 @@
#ifndef __BRCMSTB_SOC_H
#define __BRCMSTB_SOC_H
+#define BRCM_ID(reg) ((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)
+#define BRCM_REV(reg) ((u32)reg & 0xff)
+
/*
* Bus Interface Unit control register setup, must happen early during boot,
* before SMP is brought up, called by machine entry point.
*/
void brcmstb_biuctrl_init(void);
+/*
+ * Helper functions for getting family or product id from the
+ * SoC driver.
+ */
+u32 brcmstb_get_family_id(void);
+u32 brcmstb_get_product_id(void);
+
#endif /* __BRCMSTB_SOC_H */
--
1.9.0.138.g2de3478
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-07-22 19:10 +0200 |
| Subject | Re: [PATCH v4 1/4] soc: brcmstb: Add Product ID and Family ID helper functions |
| Message-ID | <u664G-4F6-11@gated-at.bofh.it> |
| In reply to | #1693744 |
On 07/21/2017 07:10 AM, Al Cooper wrote:
> Signed-off-by: Al Cooper <alcooperx@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> drivers/soc/bcm/brcmstb/common.c | 12 ++++++++++++
> include/linux/soc/brcmstb/brcmstb.h | 10 ++++++++++
> 2 files changed, 22 insertions(+)
>
> diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c
> index b6195fd..184dbf5 100644
> --- a/drivers/soc/bcm/brcmstb/common.c
> +++ b/drivers/soc/bcm/brcmstb/common.c
> @@ -40,6 +40,18 @@ bool soc_is_brcmstb(void)
> return of_match_node(brcmstb_machine_match, root) != NULL;
> }
>
> +u32 brcmstb_get_family_id(void)
> +{
> + return family_id;
> +}
> +EXPORT_SYMBOL(brcmstb_get_family_id);
> +
> +u32 brcmstb_get_product_id(void)
> +{
> + return product_id;
> +}
> +EXPORT_SYMBOL(brcmstb_get_product_id);
> +
> static const struct of_device_id sun_top_ctrl_match[] = {
> { .compatible = "brcm,bcm7125-sun-top-ctrl", },
> { .compatible = "brcm,bcm7346-sun-top-ctrl", },
> diff --git a/include/linux/soc/brcmstb/brcmstb.h b/include/linux/soc/brcmstb/brcmstb.h
> index 337ce41..23e4dc9 100644
> --- a/include/linux/soc/brcmstb/brcmstb.h
> +++ b/include/linux/soc/brcmstb/brcmstb.h
> @@ -1,10 +1,20 @@
> #ifndef __BRCMSTB_SOC_H
> #define __BRCMSTB_SOC_H
>
> +#define BRCM_ID(reg) ((u32)reg >> 28 ? (u32)reg >> 16 : (u32)reg >> 8)
> +#define BRCM_REV(reg) ((u32)reg & 0xff)
> +
> /*
> * Bus Interface Unit control register setup, must happen early during boot,
> * before SMP is brought up, called by machine entry point.
> */
> void brcmstb_biuctrl_init(void);
>
> +/*
> + * Helper functions for getting family or product id from the
> + * SoC driver.
> + */
> +u32 brcmstb_get_family_id(void);
> +u32 brcmstb_get_product_id(void);
> +
> #endif /* __BRCMSTB_SOC_H */
>
--
Florian
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web