Re: [PATCH v2 0/2] MCAN: Add support for implementing transceiver as a phy

2021-04-16 Thread Aswath Govindraju
Hi all,

On 15/04/21 9:16 pm, Aswath Govindraju wrote:
> The following series of patches add support for implementing the
> transceiver as a phy of m_can_platform driver.
> 
> TCAN1042 has a standby signal that needs to be pulled high for
> sending/receiving messages[1]. TCAN1043 has a enable signal along with
> standby signal that needs to be pulled up for sending/receiving
> messages[2], and other combinations of the two lines can be used to put the
> transceiver in different states to reduce power consumption. On boards
> like the AM654-idk and J721e-evm these signals are controlled using gpios.
> 
> These gpios are set in phy driver, and the transceiver can be put in
> different states using phy API. The phy driver is added in the series [3].
> 
> This patch series is dependent on [4].
> 
> Changes since v1:
> - Used the API devm_phy_get_optional() instead of 
>   devm_of_phy_get_optional_by_index()
> 
> [1] - https://www.ti.com/lit/ds/symlink/tcan1042h.pdf
> [2] - https://www.ti.com/lit/ds/symlink/tcan1043-q1.pdf
> [3] - https://lore.kernel.org/patchwork/project/lkml/list/?series=495365
> [4] - https://lore.kernel.org/patchwork/patch/1413286/
> 

Posted v3 for this series.

Thanks,
Aswath

> Faiz Abbas (2):
>   dt-bindings: net: can: Document transceiver implementation as phy
>   can: m_can: Add support for transceiver as phy
> 
>  .../devicetree/bindings/net/can/bosch,m_can.yaml|  3 +++
>  drivers/net/can/m_can/m_can.c   | 10 ++
>  drivers/net/can/m_can/m_can.h   |  2 ++
>  drivers/net/can/m_can/m_can_platform.c  | 13 +
>  4 files changed, 28 insertions(+)
> 



Re: [PATCH v4 0/3] CAN TRANSCEIVER: Add support for CAN transceivers

2021-04-16 Thread Aswath Govindraju
Hi all,

On 16/04/21 10:56 am, Aswath Govindraju wrote:
> The following series of patches add support for CAN transceivers.
> 
> TCAN1042 has a standby signal that needs to be pulled high for
> sending/receiving messages[1]. TCAN1043 has a enable signal along with
> standby signal that needs to be pulled up for sending/receiving
> messages[2], and other combinations of the two lines can be used to put the
> transceiver in different states to reduce power consumption. On boards
> like the AM654-idk and J721e-evm these signals are controlled using gpios.
> 
> Patch 1 rewords the comment that restricts max_link_rate attribute to have
> units of Mbps.
> 
> Patch 2 models the transceiver as a phy device tree node with properties
> for max bit rate supported, gpio properties for indicating gpio pin numbers
> to which standby and enable signals are connected.
> 
> Patch 2 adds a generic driver to support CAN transceivers.
> 
> changes since v3:
> - dropped patch 2(in v3)
> - changed the node name property in patch 3(in v3)
> - picked up Rob Herring's reviewed-by for patch 3(in v3)
> 
> changes since v2:
> - dropped 5 and 6 patches and to be sent via linux-can-next
> - added static keyword for can_transceiver_phy_probe()
> - changed enable gpio example to active high in patch 3
> - Rearranged the file names in alphabetical order in Makefile
>   and MAINTAINERS file
> 
> changes since v1:
> - Added patch 1 (in v2) that rewords the comment that restrict
>   max_link_rate attribute to have units of Mbps.
> - Added patch 2 (in v2) that adds an API for
>   devm_of_phy_optional_get_by_index
> - Patch 1 (in v1)
>   - updated MAINTAINERS file
> - Patch 2 (in v1)
>   - replaced m_can with CAN to make the driver independent of CAN driver
>   - Added prefix CAN_TRANSCEIVER for EN_PRESENT and STB_PRESENT
>   - Added new line before return statements in power_on() and power_off
>   - Added error handling patch for devm_kzalloc()
>   - used the max_link_rate attribute directly instead of dividing it by
> 100
>   - removed the spaces before GPIOD_OUT_LOW in devm_gpiod_get()
>   - Corrected requested value for standby-gpios to GPIOD_OUT_HIGH
>   - Updated MAINTAINERS file
> - Patch 3 (in v1)
>   - replaced minItems with maxItems
>   - Removed phy-names property as there is only one phy
> - Patch 4 (in v1)
>   - replaced dev_warn with dev_info when no transceiver is found
>   - Added struct phy * field in m_can_classdev struct
>   - moved phy_power_on and phy_power_off to m_can_open and m_can_close
> respectively
>   - Moved the check for max_bit_rate to generice transceiver driver
> 
> [1] - https://www.ti.com/lit/ds/symlink/tcan1042h.pdf
> [2] - https://www.ti.com/lit/ds/symlink/tcan1043-q1.pdf
> 
> 

Posted v5 for this series.

Thanks,
Aswath

> Aswath Govindraju (3):
>   phy: core: Reword the comment specifying the units of max_link_rate to
> be Mbps
>   dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers
>   phy: phy-can-transceiver: Add support for generic CAN transceiver
> driver
> 
>  .../bindings/phy/ti,tcan104x-can.yaml |  56 +++
>  MAINTAINERS   |   2 +
>  drivers/phy/Kconfig   |   9 ++
>  drivers/phy/Makefile  |   1 +
>  drivers/phy/phy-can-transceiver.c | 146 ++
>  include/linux/phy/phy.h   |   2 +-
>  6 files changed, 215 insertions(+), 1 deletion(-)
>  create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
>  create mode 100644 drivers/phy/phy-can-transceiver.c
> 



[PATCH v3 1/2] dt-bindings: net: can: Document transceiver implementation as phy

2021-04-16 Thread Aswath Govindraju
From: Faiz Abbas 

Some transceivers need a configuration step (for example, pulling the
standby or enable lines) for them to start sending messages. The
transceiver can be implemented as a phy with the configuration done in the
phy driver. The bit rate limitation can the be obtained by the driver using
the phy node.

Document the above implementation in the bosch mcan bindings

Signed-off-by: Faiz Abbas 
Signed-off-by: Aswath Govindraju 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml 
b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
index 798fa5fb7bb2..25f74db46bae 100644
--- a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
+++ b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
@@ -109,6 +109,9 @@ properties:
   can-transceiver:
 $ref: can-transceiver.yaml#
 
+  phys:
+maxItems: 1
+
 required:
   - compatible
   - reg
-- 
2.17.1



[PATCH v3 2/2] can: m_can: Add support for transceiver as phy

2021-04-16 Thread Aswath Govindraju
From: Faiz Abbas 

Add support for implementing transceiver node as phy. The max_bitrate is
obtained by getting a phy attribute.

Signed-off-by: Faiz Abbas 
Signed-off-by: Aswath Govindraju 
---
 drivers/net/can/m_can/m_can.c  | 10 ++
 drivers/net/can/m_can/m_can.h  |  2 ++
 drivers/net/can/m_can/m_can_platform.c | 13 +
 3 files changed, 25 insertions(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 34073cd077e4..7d31250446c2 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "m_can.h"
 
@@ -1514,6 +1515,7 @@ static void m_can_stop(struct net_device *dev)
 static int m_can_close(struct net_device *dev)
 {
struct m_can_classdev *cdev = netdev_priv(dev);
+   int err;
 
netif_stop_queue(dev);
 
@@ -1536,6 +1538,10 @@ static int m_can_close(struct net_device *dev)
close_candev(dev);
can_led_event(dev, CAN_LED_EVENT_STOP);
 
+   err = phy_power_off(cdev->transceiver);
+   if (err)
+   return err;
+
return 0;
 }
 
@@ -1720,6 +1726,10 @@ static int m_can_open(struct net_device *dev)
struct m_can_classdev *cdev = netdev_priv(dev);
int err;
 
+   err = phy_power_on(cdev->transceiver);
+   if (err)
+   return err;
+
err = m_can_clk_start(cdev);
if (err)
return err;
diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h
index ace071c3e58c..38cad068abad 100644
--- a/drivers/net/can/m_can/m_can.h
+++ b/drivers/net/can/m_can/m_can.h
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* m_can lec values */
 enum m_can_lec_type {
@@ -82,6 +83,7 @@ struct m_can_classdev {
struct workqueue_struct *tx_wq;
struct work_struct tx_work;
struct sk_buff *tx_skb;
+   struct phy *transceiver;
 
struct can_bittiming_const *bit_timing;
struct can_bittiming_const *data_timing;
diff --git a/drivers/net/can/m_can/m_can_platform.c 
b/drivers/net/can/m_can/m_can_platform.c
index 599de0e08cd7..f102d532b7f0 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -6,6 +6,7 @@
 // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
 
 #include 
+#include 
 
 #include "m_can.h"
 
@@ -67,6 +68,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
struct resource *res;
void __iomem *addr;
void __iomem *mram_addr;
+   struct phy *transceiver;
int irq, ret = 0;
 
mcan_class = m_can_class_allocate_dev(>dev,
@@ -101,6 +103,16 @@ static int m_can_plat_probe(struct platform_device *pdev)
goto probe_fail;
}
 
+   transceiver = devm_phy_optional_get(>dev, NULL);
+   if (IS_ERR(transceiver)) {
+   ret = PTR_ERR(transceiver);
+   dev_err_probe(>dev, ret, "failed to get phy\n");
+   return ret;
+   }
+
+   if (transceiver)
+   mcan_class->can.bitrate_max = transceiver->attrs.max_link_rate;
+
priv->base = addr;
priv->mram_base = mram_addr;
 
@@ -108,6 +120,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
mcan_class->pm_clock_support = 1;
mcan_class->can.clock.freq = clk_get_rate(mcan_class->cclk);
mcan_class->dev = >dev;
+   mcan_class->transceiver = transceiver;
 
mcan_class->ops = _can_plat_ops;
 
-- 
2.17.1



[PATCH v3 0/2] MCAN: Add support for implementing transceiver as a phy

2021-04-16 Thread Aswath Govindraju
The following series of patches add support for implementing the
transceiver as a phy of m_can_platform driver.

TCAN1042 has a standby signal that needs to be pulled high for
sending/receiving messages[1]. TCAN1043 has a enable signal along with
standby signal that needs to be pulled up for sending/receiving
messages[2], and other combinations of the two lines can be used to put the
transceiver in different states to reduce power consumption. On boards
like the AM654-idk and J721e-evm these signals are controlled using gpios.

These gpios are set in phy driver, and the transceiver can be put in
different states using phy API. The phy driver is added in the series [3].

This patch series is dependent on [4].

changes since v2:
- changed dev_err to dev_err_probe in patch 2
- used mcan_class instead of priv to assign max bit rate
- Picked up  Rob Herring's acked-by for patch 1

changes since v1:
- Used the API devm_phy_get_optional() instead of 
  devm_of_phy_get_optional_by_index()

[1] - https://www.ti.com/lit/ds/symlink/tcan1042h.pdf
[2] - https://www.ti.com/lit/ds/symlink/tcan1043-q1.pdf
[3] - https://lore.kernel.org/patchwork/project/lkml/list/?series=495511
[4] - https://lore.kernel.org/patchwork/patch/1413286/

Faiz Abbas (2):
  dt-bindings: net: can: Document transceiver implementation as phy
  can: m_can: Add support for transceiver as phy

 .../devicetree/bindings/net/can/bosch,m_can.yaml|  3 +++
 drivers/net/can/m_can/m_can.c   | 10 ++
 drivers/net/can/m_can/m_can.h   |  2 ++
 drivers/net/can/m_can/m_can_platform.c  | 13 +
 4 files changed, 28 insertions(+)

-- 
2.17.1



[PATCH v5 0/3] CAN TRANSCEIVER: Add support for CAN transceivers

2021-04-16 Thread Aswath Govindraju
The following series of patches add support for CAN transceivers.

TCAN1042 has a standby signal that needs to be pulled high for
sending/receiving messages[1]. TCAN1043 has a enable signal along with
standby signal that needs to be pulled up for sending/receiving
messages[2], and other combinations of the two lines can be used to put the
transceiver in different states to reduce power consumption. On boards
like the AM654-idk and J721e-evm these signals are controlled using gpios.

Patch 1 rewords the comment that restricts max_link_rate attribute to have
units of Mbps.

Patch 2 models the transceiver as a phy device tree node with properties
for max bit rate supported, gpio properties for indicating gpio pin numbers
to which standby and enable signals are connected.

Patch 2 adds a generic driver to support CAN transceivers.

changes since v4:
- In patch 3 made the correction from mcan to CAN, in Kconfig help

changes since v3:
- dropped patch 2(in v3)
- changed the node name property in patch 3(in v3)
- picked up Rob Herring's reviewed-by for patch 3(in v3)

changes since v2:
- dropped 5 and 6 patches and to be sent via linux-can-next
- added static keyword for can_transceiver_phy_probe()
- changed enable gpio example to active high in patch 3
- Rearranged the file names in alphabetical order in Makefile
  and MAINTAINERS file

changes since v1:
- Added patch 1 (in v2) that rewords the comment that restrict
  max_link_rate attribute to have units of Mbps.
- Added patch 2 (in v2) that adds an API for
  devm_of_phy_optional_get_by_index
- Patch 1 (in v1)
  - updated MAINTAINERS file
- Patch 2 (in v1)
  - replaced m_can with CAN to make the driver independent of CAN driver
  - Added prefix CAN_TRANSCEIVER for EN_PRESENT and STB_PRESENT
  - Added new line before return statements in power_on() and power_off
  - Added error handling patch for devm_kzalloc()
  - used the max_link_rate attribute directly instead of dividing it by
100
  - removed the spaces before GPIOD_OUT_LOW in devm_gpiod_get()
  - Corrected requested value for standby-gpios to GPIOD_OUT_HIGH
  - Updated MAINTAINERS file
- Patch 3 (in v1)
  - replaced minItems with maxItems
  - Removed phy-names property as there is only one phy
- Patch 4 (in v1)
  - replaced dev_warn with dev_info when no transceiver is found
  - Added struct phy * field in m_can_classdev struct
  - moved phy_power_on and phy_power_off to m_can_open and m_can_close
respectively
  - Moved the check for max_bit_rate to generice transceiver driver

[1] - https://www.ti.com/lit/ds/symlink/tcan1042h.pdf
[2] - https://www.ti.com/lit/ds/symlink/tcan1043-q1.pdf

Aswath Govindraju (3):
  phy: core: Reword the comment specifying the units of max_link_rate to
be Mbps
  dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers
  phy: phy-can-transceiver: Add support for generic CAN transceiver
driver

 .../bindings/phy/ti,tcan104x-can.yaml |  56 +++
 MAINTAINERS   |   2 +
 drivers/phy/Kconfig   |   9 ++
 drivers/phy/Makefile  |   1 +
 drivers/phy/phy-can-transceiver.c | 146 ++
 include/linux/phy/phy.h   |   2 +-
 6 files changed, 215 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
 create mode 100644 drivers/phy/phy-can-transceiver.c

-- 
2.17.1



[PATCH v5 3/3] phy: phy-can-transceiver: Add support for generic CAN transceiver driver

2021-04-16 Thread Aswath Govindraju
The driver adds support for generic CAN transceivers. Currently
the modes supported by this driver are standby and normal modes for TI
TCAN1042 and TCAN1043 CAN transceivers.

The transceiver is modelled as a phy with pins controlled by gpios, to put
the transceiver in various device functional modes. It also gets the phy
attribute max_link_rate for the usage of CAN drivers.

Signed-off-by: Aswath Govindraju 
---
 MAINTAINERS   |   1 +
 drivers/phy/Kconfig   |   9 ++
 drivers/phy/Makefile  |   1 +
 drivers/phy/phy-can-transceiver.c | 146 ++
 4 files changed, 157 insertions(+)
 create mode 100644 drivers/phy/phy-can-transceiver.c

diff --git a/MAINTAINERS b/MAINTAINERS
index e666d33af10d..4e868f2a97c7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4048,6 +4048,7 @@ T:git 
git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git
 F: Documentation/devicetree/bindings/net/can/
 F: Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
 F: drivers/net/can/
+F: drivers/phy/phy-can-transceiver.c
 F: include/linux/can/bittiming.h
 F: include/linux/can/dev.h
 F: include/linux/can/led.h
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 54c1f2f0985f..7dd35f1b9cc5 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -61,6 +61,15 @@ config USB_LGM_PHY
  interface to interact with USB GEN-II and USB 3.x PHY that is part
  of the Intel network SOC.
 
+config PHY_CAN_TRANSCEIVER
+   tristate "CAN transceiver PHY"
+   select GENERIC_PHY
+   help
+ This option enables support for CAN transceivers as a PHY. This
+ driver provides function for putting the transceivers in various
+ functional modes using gpios and sets the attribute max link
+ rate, for CAN drivers.
+
 source "drivers/phy/allwinner/Kconfig"
 source "drivers/phy/amlogic/Kconfig"
 source "drivers/phy/broadcom/Kconfig"
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index adac1b1a39d1..01e9efffc726 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -5,6 +5,7 @@
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
 obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY)+= phy-core-mipi-dphy.o
+obj-$(CONFIG_PHY_CAN_TRANSCEIVER)  += phy-can-transceiver.o
 obj-$(CONFIG_PHY_LPC18XX_USB_OTG)  += phy-lpc18xx-usb-otg.o
 obj-$(CONFIG_PHY_XGENE)+= phy-xgene.o
 obj-$(CONFIG_PHY_PISTACHIO_USB)+= phy-pistachio-usb.o
diff --git a/drivers/phy/phy-can-transceiver.c 
b/drivers/phy/phy-can-transceiver.c
new file mode 100644
index ..c24aa2eab9e4
--- /dev/null
+++ b/drivers/phy/phy-can-transceiver.c
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * phy-can-transceiver.c - phy driver for CAN transceivers
+ *
+ * Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com
+ *
+ */
+#include
+#include
+#include
+#include
+#include
+
+struct can_transceiver_data {
+   u32 flags;
+#define CAN_TRANSCEIVER_STB_PRESENTBIT(0)
+#define CAN_TRANSCEIVER_EN_PRESENT BIT(1)
+};
+
+struct can_transceiver_phy {
+   struct phy *generic_phy;
+   struct gpio_desc *standby_gpio;
+   struct gpio_desc *enable_gpio;
+};
+
+/* Power on function */
+static int can_transceiver_phy_power_on(struct phy *phy)
+{
+   struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
+
+   if (can_transceiver_phy->standby_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
+   if (can_transceiver_phy->enable_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1);
+
+   return 0;
+}
+
+/* Power off function */
+static int can_transceiver_phy_power_off(struct phy *phy)
+{
+   struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
+
+   if (can_transceiver_phy->standby_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1);
+   if (can_transceiver_phy->enable_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 0);
+
+   return 0;
+}
+
+static const struct phy_ops can_transceiver_phy_ops = {
+   .power_on   = can_transceiver_phy_power_on,
+   .power_off  = can_transceiver_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
+static const struct can_transceiver_data tcan1042_drvdata = {
+   .flags = CAN_TRANSCEIVER_STB_PRESENT,
+};
+
+static const struct can_transceiver_data tcan1043_drvdata = {
+   .flags = CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_EN_PRESENT,
+};
+
+static const struct of_device_id can_transceiver_phy_ids[] = {
+   {
+   .compatible = "ti,tcan1042",
+   .data = _drvdata
+   },
+   {
+   .compatible = "ti,tcan1043",
+   .data = 

[PATCH v5 2/3] dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers

2021-04-16 Thread Aswath Govindraju
Add binding documentation for TI TCAN104x CAN transceivers.

Signed-off-by: Aswath Govindraju 
Reviewed-by: Rob Herring 
---
 .../bindings/phy/ti,tcan104x-can.yaml | 56 +++
 MAINTAINERS   |  1 +
 2 files changed, 57 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml

diff --git a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml 
b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
new file mode 100644
index ..6107880e5246
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/phy/ti,tcan104x-can.yaml#;
+$schema: "http://devicetree.org/meta-schemas/core.yaml#;
+
+title: TCAN104x CAN TRANSCEIVER PHY
+
+maintainers:
+  - Aswath Govindraju 
+
+properties:
+  $nodename:
+pattern: "^can-phy"
+
+  compatible:
+enum:
+  - ti,tcan1042
+  - ti,tcan1043
+
+  '#phy-cells':
+const: 0
+
+  standby-gpios:
+description:
+  gpio node to toggle standby signal on transceiver
+maxItems: 1
+
+  enable-gpios:
+description:
+  gpio node to toggle enable signal on transceiver
+maxItems: 1
+
+  max-bitrate:
+$ref: /schemas/types.yaml#/definitions/uint32
+description:
+  max bit rate supported in bps
+minimum: 1
+
+required:
+  - compatible
+  - '#phy-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+transceiver1: can-phy {
+  compatible = "ti,tcan1043";
+  #phy-cells = <0>;
+  max-bitrate = <500>;
+  standby-gpios = <_gpio1 16 GPIO_ACTIVE_LOW>;
+  enable-gpios = <_gpio1 67 GPIO_ACTIVE_HIGH>;
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index 84ef96a444c3..e666d33af10d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4046,6 +4046,7 @@ W:https://github.com/linux-can
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git
 F: Documentation/devicetree/bindings/net/can/
+F: Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
 F: drivers/net/can/
 F: include/linux/can/bittiming.h
 F: include/linux/can/dev.h
-- 
2.17.1



[PATCH v5 1/3] phy: core: Reword the comment specifying the units of max_link_rate to be Mbps

2021-04-16 Thread Aswath Govindraju
In some subsystems (eg. CAN, SPI), the max link rate supported can be less
than 1 Mbps and if the unit for max_link_rate is Mbps then it can't be
used. Therefore, leave the decision of units to be used, to the producer
and consumer.

Signed-off-by: Aswath Govindraju 
---
 include/linux/phy/phy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 0ed434d02196..f3286f4cd306 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -125,7 +125,7 @@ struct phy_ops {
 /**
  * struct phy_attrs - represents phy attributes
  * @bus_width: Data path width implemented by PHY
- * @max_link_rate: Maximum link rate supported by PHY (in Mbps)
+ * @max_link_rate: Maximum link rate supported by PHY (units to be decided by 
producer and consumer)
  * @mode: PHY mode
  */
 struct phy_attrs {
-- 
2.17.1



Re: [PATCH v3 0/4] CAN TRANSCEIVER: Add support for CAN transceivers

2021-04-15 Thread Aswath Govindraju
Hi all,

On 15/04/21 8:19 pm, Aswath Govindraju wrote:
> The following series of patches add support for CAN transceivers.
> 
> TCAN1042 has a standby signal that needs to be pulled high for
> sending/receiving messages[1]. TCAN1043 has a enable signal along with
> standby signal that needs to be pulled up for sending/receiving
> messages[2], and other combinations of the two lines can be used to put the
> transceiver in different states to reduce power consumption. On boards
> like the AM654-idk and J721e-evm these signals are controlled using gpios.
> 
> Patch 1 rewords the comment that restricts max_link_rate attribute to have
> units of Mbps.
> 
> Patch 2 adds an API for devm_of_phy_optional_get_by_index
> 
> Patch 3 models the transceiver as a phy device tree node with properties
> for max bit rate supported, gpio properties for indicating gpio pin numbers
> to which standby and enable signals are connected.
> 
> Patch 4 adds a generic driver to support CAN transceivers.
> 
> changes since v2:
> - dropped 5 and 6 patches and to be sent via linux-can-next
> - added static keyword for can_transceiver_phy_probe()
> - changed enable gpio example to active high in patch 3
> - Rearranged the file names in alphabetical order in Makefile
>   and MAINTAINERS file
> 
> changes since v1:
> - Added patch 1 (in v2) that rewords the comment that restrict
>   max_link_rate attribute to have units of Mbps.
> - Added patch 2 (in v2) that adds an API for
>   devm_of_phy_optional_get_by_index
> - Patch 1 (in v1)
>   - updated MAINTAINERS file
> - Patch 2 (in v1)
>   - replaced m_can with CAN to make the driver independent of CAN driver
>   - Added prefix CAN_TRANSCEIVER for EN_PRESENT and STB_PRESENT
>   - Added new line before return statements in power_on() and power_off
>   - Added error handling patch for devm_kzalloc()
>   - used the max_link_rate attribute directly instead of dividing it by
> 100
>   - removed the spaces before GPIOD_OUT_LOW in devm_gpiod_get()
>   - Corrected requested value for standby-gpios to GPIOD_OUT_HIGH
>   - Updated MAINTAINERS file
> - Patch 3 (in v1)
>   - replaced minItems with maxItems
>   - Removed phy-names property as there is only one phy
> - Patch 4 (in v1)
>   - replaced dev_warn with dev_info when no transceiver is found
>   - Added struct phy * field in m_can_classdev struct
>   - moved phy_power_on and phy_power_off to m_can_open and m_can_close
> respectively
>   - Moved the check for max_bit_rate to generice transceiver driver
> 
> [1] - https://www.ti.com/lit/ds/symlink/tcan1042h.pdf
> [2] - https://www.ti.com/lit/ds/symlink/tcan1043-q1.pdf
> 

Posted v4 for this series.

Thanks,
Aswath

> Aswath Govindraju (4):
>   phy: core: Reword the comment specifying the units of max_link_rate to
> be Mbps
>   phy: Add API for devm_of_phy_optional_get_by_index
>   dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers
>   phy: phy-can-transceiver: Add support for generic CAN transceiver
> driver
> 
>  .../bindings/phy/ti,tcan104x-can.yaml |  56 +++
>  MAINTAINERS   |   2 +
>  drivers/phy/Kconfig   |   9 ++
>  drivers/phy/Makefile  |   1 +
>  drivers/phy/phy-can-transceiver.c | 146 ++
>  drivers/phy/phy-core.c|  26 
>  include/linux/phy/phy.h   |   4 +-
>  7 files changed, 243 insertions(+), 1 deletion(-)
>  create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
>  create mode 100644 drivers/phy/phy-can-transceiver.c
> 



[PATCH v4 3/3] phy: phy-can-transceiver: Add support for generic CAN transceiver driver

2021-04-15 Thread Aswath Govindraju
The driver adds support for generic CAN transceivers. Currently
the modes supported by this driver are standby and normal modes for TI
TCAN1042 and TCAN1043 CAN transceivers.

The transceiver is modelled as a phy with pins controlled by gpios, to put
the transceiver in various device functional modes. It also gets the phy
attribute max_link_rate for the usage of CAN drivers.

Signed-off-by: Aswath Govindraju 
---
 MAINTAINERS   |   1 +
 drivers/phy/Kconfig   |   9 ++
 drivers/phy/Makefile  |   1 +
 drivers/phy/phy-can-transceiver.c | 146 ++
 4 files changed, 157 insertions(+)
 create mode 100644 drivers/phy/phy-can-transceiver.c

diff --git a/MAINTAINERS b/MAINTAINERS
index e666d33af10d..4e868f2a97c7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4048,6 +4048,7 @@ T:git 
git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git
 F: Documentation/devicetree/bindings/net/can/
 F: Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
 F: drivers/net/can/
+F: drivers/phy/phy-can-transceiver.c
 F: include/linux/can/bittiming.h
 F: include/linux/can/dev.h
 F: include/linux/can/led.h
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 54c1f2f0985f..51902b629fc6 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -61,6 +61,15 @@ config USB_LGM_PHY
  interface to interact with USB GEN-II and USB 3.x PHY that is part
  of the Intel network SOC.
 
+config PHY_CAN_TRANSCEIVER
+   tristate "CAN transceiver PHY"
+   select GENERIC_PHY
+   help
+ This option enables support for CAN transceivers as a PHY. This
+ driver provides function for putting the transceivers in various
+ functional modes using gpios and sets the attribute max link
+ rate, for mcan drivers.
+
 source "drivers/phy/allwinner/Kconfig"
 source "drivers/phy/amlogic/Kconfig"
 source "drivers/phy/broadcom/Kconfig"
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index adac1b1a39d1..01e9efffc726 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -5,6 +5,7 @@
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
 obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY)+= phy-core-mipi-dphy.o
+obj-$(CONFIG_PHY_CAN_TRANSCEIVER)  += phy-can-transceiver.o
 obj-$(CONFIG_PHY_LPC18XX_USB_OTG)  += phy-lpc18xx-usb-otg.o
 obj-$(CONFIG_PHY_XGENE)+= phy-xgene.o
 obj-$(CONFIG_PHY_PISTACHIO_USB)+= phy-pistachio-usb.o
diff --git a/drivers/phy/phy-can-transceiver.c 
b/drivers/phy/phy-can-transceiver.c
new file mode 100644
index ..c24aa2eab9e4
--- /dev/null
+++ b/drivers/phy/phy-can-transceiver.c
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * phy-can-transceiver.c - phy driver for CAN transceivers
+ *
+ * Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com
+ *
+ */
+#include
+#include
+#include
+#include
+#include
+
+struct can_transceiver_data {
+   u32 flags;
+#define CAN_TRANSCEIVER_STB_PRESENTBIT(0)
+#define CAN_TRANSCEIVER_EN_PRESENT BIT(1)
+};
+
+struct can_transceiver_phy {
+   struct phy *generic_phy;
+   struct gpio_desc *standby_gpio;
+   struct gpio_desc *enable_gpio;
+};
+
+/* Power on function */
+static int can_transceiver_phy_power_on(struct phy *phy)
+{
+   struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
+
+   if (can_transceiver_phy->standby_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
+   if (can_transceiver_phy->enable_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1);
+
+   return 0;
+}
+
+/* Power off function */
+static int can_transceiver_phy_power_off(struct phy *phy)
+{
+   struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
+
+   if (can_transceiver_phy->standby_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1);
+   if (can_transceiver_phy->enable_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 0);
+
+   return 0;
+}
+
+static const struct phy_ops can_transceiver_phy_ops = {
+   .power_on   = can_transceiver_phy_power_on,
+   .power_off  = can_transceiver_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
+static const struct can_transceiver_data tcan1042_drvdata = {
+   .flags = CAN_TRANSCEIVER_STB_PRESENT,
+};
+
+static const struct can_transceiver_data tcan1043_drvdata = {
+   .flags = CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_EN_PRESENT,
+};
+
+static const struct of_device_id can_transceiver_phy_ids[] = {
+   {
+   .compatible = "ti,tcan1042",
+   .data = _drvdata
+   },
+   {
+   .compatible = "ti,tcan1043",
+   .data = 

[PATCH v4 0/3] CAN TRANSCEIVER: Add support for CAN transceivers

2021-04-15 Thread Aswath Govindraju
The following series of patches add support for CAN transceivers.

TCAN1042 has a standby signal that needs to be pulled high for
sending/receiving messages[1]. TCAN1043 has a enable signal along with
standby signal that needs to be pulled up for sending/receiving
messages[2], and other combinations of the two lines can be used to put the
transceiver in different states to reduce power consumption. On boards
like the AM654-idk and J721e-evm these signals are controlled using gpios.

Patch 1 rewords the comment that restricts max_link_rate attribute to have
units of Mbps.

Patch 2 models the transceiver as a phy device tree node with properties
for max bit rate supported, gpio properties for indicating gpio pin numbers
to which standby and enable signals are connected.

Patch 2 adds a generic driver to support CAN transceivers.

changes since v3:
- dropped patch 2(in v3)
- changed the node name property in patch 3(in v3)
- picked up Rob Herring's reviewed-by for patch 3(in v3)

changes since v2:
- dropped 5 and 6 patches and to be sent via linux-can-next
- added static keyword for can_transceiver_phy_probe()
- changed enable gpio example to active high in patch 3
- Rearranged the file names in alphabetical order in Makefile
  and MAINTAINERS file

changes since v1:
- Added patch 1 (in v2) that rewords the comment that restrict
  max_link_rate attribute to have units of Mbps.
- Added patch 2 (in v2) that adds an API for
  devm_of_phy_optional_get_by_index
- Patch 1 (in v1)
  - updated MAINTAINERS file
- Patch 2 (in v1)
  - replaced m_can with CAN to make the driver independent of CAN driver
  - Added prefix CAN_TRANSCEIVER for EN_PRESENT and STB_PRESENT
  - Added new line before return statements in power_on() and power_off
  - Added error handling patch for devm_kzalloc()
  - used the max_link_rate attribute directly instead of dividing it by
100
  - removed the spaces before GPIOD_OUT_LOW in devm_gpiod_get()
  - Corrected requested value for standby-gpios to GPIOD_OUT_HIGH
  - Updated MAINTAINERS file
- Patch 3 (in v1)
  - replaced minItems with maxItems
  - Removed phy-names property as there is only one phy
- Patch 4 (in v1)
  - replaced dev_warn with dev_info when no transceiver is found
  - Added struct phy * field in m_can_classdev struct
  - moved phy_power_on and phy_power_off to m_can_open and m_can_close
respectively
  - Moved the check for max_bit_rate to generice transceiver driver

[1] - https://www.ti.com/lit/ds/symlink/tcan1042h.pdf
[2] - https://www.ti.com/lit/ds/symlink/tcan1043-q1.pdf


Aswath Govindraju (3):
  phy: core: Reword the comment specifying the units of max_link_rate to
be Mbps
  dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers
  phy: phy-can-transceiver: Add support for generic CAN transceiver
driver

 .../bindings/phy/ti,tcan104x-can.yaml |  56 +++
 MAINTAINERS   |   2 +
 drivers/phy/Kconfig   |   9 ++
 drivers/phy/Makefile  |   1 +
 drivers/phy/phy-can-transceiver.c | 146 ++
 include/linux/phy/phy.h   |   2 +-
 6 files changed, 215 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
 create mode 100644 drivers/phy/phy-can-transceiver.c

-- 
2.17.1



[PATCH v4 2/3] dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers

2021-04-15 Thread Aswath Govindraju
Add binding documentation for TI TCAN104x CAN transceivers.

Signed-off-by: Aswath Govindraju 
Reviewed-by: Rob Herring 
---
 .../bindings/phy/ti,tcan104x-can.yaml | 56 +++
 MAINTAINERS   |  1 +
 2 files changed, 57 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml

diff --git a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml 
b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
new file mode 100644
index ..6107880e5246
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/phy/ti,tcan104x-can.yaml#;
+$schema: "http://devicetree.org/meta-schemas/core.yaml#;
+
+title: TCAN104x CAN TRANSCEIVER PHY
+
+maintainers:
+  - Aswath Govindraju 
+
+properties:
+  $nodename:
+pattern: "^can-phy"
+
+  compatible:
+enum:
+  - ti,tcan1042
+  - ti,tcan1043
+
+  '#phy-cells':
+const: 0
+
+  standby-gpios:
+description:
+  gpio node to toggle standby signal on transceiver
+maxItems: 1
+
+  enable-gpios:
+description:
+  gpio node to toggle enable signal on transceiver
+maxItems: 1
+
+  max-bitrate:
+$ref: /schemas/types.yaml#/definitions/uint32
+description:
+  max bit rate supported in bps
+minimum: 1
+
+required:
+  - compatible
+  - '#phy-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+transceiver1: can-phy {
+  compatible = "ti,tcan1043";
+  #phy-cells = <0>;
+  max-bitrate = <500>;
+  standby-gpios = <_gpio1 16 GPIO_ACTIVE_LOW>;
+  enable-gpios = <_gpio1 67 GPIO_ACTIVE_HIGH>;
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index 84ef96a444c3..e666d33af10d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4046,6 +4046,7 @@ W:https://github.com/linux-can
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git
 F: Documentation/devicetree/bindings/net/can/
+F: Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
 F: drivers/net/can/
 F: include/linux/can/bittiming.h
 F: include/linux/can/dev.h
-- 
2.17.1



[PATCH v4 1/3] phy: core: Reword the comment specifying the units of max_link_rate to be Mbps

2021-04-15 Thread Aswath Govindraju
In some subsystems (eg. CAN, SPI), the max link rate supported can be less
than 1 Mbps and if the unit for max_link_rate is Mbps then it can't be
used. Therefore, leave the decision of units to be used, to the producer
and consumer.

Signed-off-by: Aswath Govindraju 
---
 include/linux/phy/phy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 0ed434d02196..f3286f4cd306 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -125,7 +125,7 @@ struct phy_ops {
 /**
  * struct phy_attrs - represents phy attributes
  * @bus_width: Data path width implemented by PHY
- * @max_link_rate: Maximum link rate supported by PHY (in Mbps)
+ * @max_link_rate: Maximum link rate supported by PHY (units to be decided by 
producer and consumer)
  * @mode: PHY mode
  */
 struct phy_attrs {
-- 
2.17.1



Re: [PATCH 0/2] MCAN: Add support for implementing transceiver as a phy

2021-04-15 Thread Aswath Govindraju
Hi all,

On 15/04/21 8:36 pm, Aswath Govindraju wrote:
> The following series of patches add support for implementing the
> transceiver as a phy of m_can_platform driver.
> 
> TCAN1042 has a standby signal that needs to be pulled high for
> sending/receiving messages[1]. TCAN1043 has a enable signal along with
> standby signal that needs to be pulled up for sending/receiving
> messages[2], and other combinations of the two lines can be used to put the
> transceiver in different states to reduce power consumption. On boards
> like the AM654-idk and J721e-evm these signals are controlled using gpios.
> 
> These gpios are set in phy driver, and the transceiver can be put in
> different states using phy API. The phy driver is added in the series [3].
> 
> [1] - https://www.ti.com/lit/ds/symlink/tcan1042h.pdf
> [2] - https://www.ti.com/lit/ds/symlink/tcan1043-q1.pdf
> [3] - https://lore.kernel.org/patchwork/project/lkml/list/?series=495365
> 

Posted v2 for this series.

Thanks,
Aswath

> Faiz Abbas (2):
>   dt-bindings: net: can: Document transceiver implementation as phy
>   can: m_can: Add support for transceiver as phy
> 
>  .../devicetree/bindings/net/can/bosch,m_can.yaml|  3 +++
>  drivers/net/can/m_can/m_can.c   | 10 ++
>  drivers/net/can/m_can/m_can.h   |  2 ++
>  drivers/net/can/m_can/m_can_platform.c  | 13 +
>  4 files changed, 28 insertions(+)
> 



[PATCH v2 2/2] can: m_can: Add support for transceiver as phy

2021-04-15 Thread Aswath Govindraju
From: Faiz Abbas 

Add support for implementing transceiver node as phy. The max_bitrate is
obtained by getting a phy attribute.

Signed-off-by: Faiz Abbas 
Signed-off-by: Aswath Govindraju 
---
 drivers/net/can/m_can/m_can.c  | 10 ++
 drivers/net/can/m_can/m_can.h  |  2 ++
 drivers/net/can/m_can/m_can_platform.c | 13 +
 3 files changed, 25 insertions(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 34073cd077e4..7d31250446c2 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "m_can.h"
 
@@ -1514,6 +1515,7 @@ static void m_can_stop(struct net_device *dev)
 static int m_can_close(struct net_device *dev)
 {
struct m_can_classdev *cdev = netdev_priv(dev);
+   int err;
 
netif_stop_queue(dev);
 
@@ -1536,6 +1538,10 @@ static int m_can_close(struct net_device *dev)
close_candev(dev);
can_led_event(dev, CAN_LED_EVENT_STOP);
 
+   err = phy_power_off(cdev->transceiver);
+   if (err)
+   return err;
+
return 0;
 }
 
@@ -1720,6 +1726,10 @@ static int m_can_open(struct net_device *dev)
struct m_can_classdev *cdev = netdev_priv(dev);
int err;
 
+   err = phy_power_on(cdev->transceiver);
+   if (err)
+   return err;
+
err = m_can_clk_start(cdev);
if (err)
return err;
diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h
index ace071c3e58c..38cad068abad 100644
--- a/drivers/net/can/m_can/m_can.h
+++ b/drivers/net/can/m_can/m_can.h
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* m_can lec values */
 enum m_can_lec_type {
@@ -82,6 +83,7 @@ struct m_can_classdev {
struct workqueue_struct *tx_wq;
struct work_struct tx_work;
struct sk_buff *tx_skb;
+   struct phy *transceiver;
 
struct can_bittiming_const *bit_timing;
struct can_bittiming_const *data_timing;
diff --git a/drivers/net/can/m_can/m_can_platform.c 
b/drivers/net/can/m_can/m_can_platform.c
index 599de0e08cd7..82d4f1a15dd7 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -6,6 +6,7 @@
 // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
 
 #include 
+#include 
 
 #include "m_can.h"
 
@@ -67,6 +68,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
struct resource *res;
void __iomem *addr;
void __iomem *mram_addr;
+   struct phy *transceiver;
int irq, ret = 0;
 
mcan_class = m_can_class_allocate_dev(>dev,
@@ -101,6 +103,16 @@ static int m_can_plat_probe(struct platform_device *pdev)
goto probe_fail;
}
 
+   transceiver = devm_phy_optional_get(>dev, NULL);
+   if (IS_ERR(transceiver)) {
+   ret = PTR_ERR(transceiver);
+   dev_err(>dev, "error while getting phy, err=%d\n", ret);
+   return ret;
+   }
+
+   if (transceiver)
+   priv->cdev.can.bitrate_max = transceiver->attrs.max_link_rate;
+
priv->base = addr;
priv->mram_base = mram_addr;
 
@@ -108,6 +120,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
mcan_class->pm_clock_support = 1;
mcan_class->can.clock.freq = clk_get_rate(mcan_class->cclk);
mcan_class->dev = >dev;
+   mcan_class->transceiver = transceiver;
 
mcan_class->ops = _can_plat_ops;
 
-- 
2.17.1



[PATCH v2 1/2] dt-bindings: net: can: Document transceiver implementation as phy

2021-04-15 Thread Aswath Govindraju
From: Faiz Abbas 

Some transceivers need a configuration step (for example, pulling the
standby or enable lines) for them to start sending messages. The
transceiver can be implemented as a phy with the configuration done in the
phy driver. The bit rate limitation can the be obtained by the driver using
the phy node.

Document the above implementation in the bosch mcan bindings

Signed-off-by: Faiz Abbas 
Signed-off-by: Aswath Govindraju 
---
 Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml 
b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
index 798fa5fb7bb2..25f74db46bae 100644
--- a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
+++ b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
@@ -109,6 +109,9 @@ properties:
   can-transceiver:
 $ref: can-transceiver.yaml#
 
+  phys:
+maxItems: 1
+
 required:
   - compatible
   - reg
-- 
2.17.1



[PATCH v2 0/2] MCAN: Add support for implementing transceiver as a phy

2021-04-15 Thread Aswath Govindraju
The following series of patches add support for implementing the
transceiver as a phy of m_can_platform driver.

TCAN1042 has a standby signal that needs to be pulled high for
sending/receiving messages[1]. TCAN1043 has a enable signal along with
standby signal that needs to be pulled up for sending/receiving
messages[2], and other combinations of the two lines can be used to put the
transceiver in different states to reduce power consumption. On boards
like the AM654-idk and J721e-evm these signals are controlled using gpios.

These gpios are set in phy driver, and the transceiver can be put in
different states using phy API. The phy driver is added in the series [3].

This patch series is dependent on [4].

Changes since v1:
- Used the API devm_phy_get_optional() instead of 
  devm_of_phy_get_optional_by_index()

[1] - https://www.ti.com/lit/ds/symlink/tcan1042h.pdf
[2] - https://www.ti.com/lit/ds/symlink/tcan1043-q1.pdf
[3] - https://lore.kernel.org/patchwork/project/lkml/list/?series=495365
[4] - https://lore.kernel.org/patchwork/patch/1413286/

Faiz Abbas (2):
  dt-bindings: net: can: Document transceiver implementation as phy
  can: m_can: Add support for transceiver as phy

 .../devicetree/bindings/net/can/bosch,m_can.yaml|  3 +++
 drivers/net/can/m_can/m_can.c   | 10 ++
 drivers/net/can/m_can/m_can.h   |  2 ++
 drivers/net/can/m_can/m_can_platform.c  | 13 +
 4 files changed, 28 insertions(+)

-- 
2.17.1



Re: [PATCH 0/2] MCAN: Add support for implementing transceiver as a phy

2021-04-15 Thread Aswath Govindraju
Hi all,

On 15/04/21 8:36 pm, Aswath Govindraju wrote:
> The following series of patches add support for implementing the
> transceiver as a phy of m_can_platform driver.
> 
> TCAN1042 has a standby signal that needs to be pulled high for
> sending/receiving messages[1]. TCAN1043 has a enable signal along with
> standby signal that needs to be pulled up for sending/receiving
> messages[2], and other combinations of the two lines can be used to put the
> transceiver in different states to reduce power consumption. On boards
> like the AM654-idk and J721e-evm these signals are controlled using gpios.
> 
> These gpios are set in phy driver, and the transceiver can be put in
> different states using phy API. The phy driver is added in the series [3].
> 
> [1] - https://www.ti.com/lit/ds/symlink/tcan1042h.pdf
> [2] - https://www.ti.com/lit/ds/symlink/tcan1043-q1.pdf
> [3] - https://lore.kernel.org/patchwork/project/lkml/list/?series=495365
> 

Please ignore this series. I will post a respin using
devm_phy_get_optional instead of devm_of_phy_get_optional_by_index()
based on the comments below[1]. Sorry for the noise.

[1] - https://lore.kernel.org/patchwork/patch/1413931/

Thanks,
Aswath

> Faiz Abbas (2):
>   dt-bindings: net: can: Document transceiver implementation as phy
>   can: m_can: Add support for transceiver as phy
> 
>  .../devicetree/bindings/net/can/bosch,m_can.yaml|  3 +++
>  drivers/net/can/m_can/m_can.c   | 10 ++
>  drivers/net/can/m_can/m_can.h   |  2 ++
>  drivers/net/can/m_can/m_can_platform.c  | 13 +
>  4 files changed, 28 insertions(+)
> 



[PATCH 2/2] can: m_can: Add support for transceiver as phy

2021-04-15 Thread Aswath Govindraju
From: Faiz Abbas 

Add support for implementing transceiver node as phy. The max_bitrate is
obtained by getting a phy attribute.

Signed-off-by: Faiz Abbas 
Signed-off-by: Aswath Govindraju 
---
 drivers/net/can/m_can/m_can.c  | 10 ++
 drivers/net/can/m_can/m_can.h  |  2 ++
 drivers/net/can/m_can/m_can_platform.c | 13 +
 3 files changed, 25 insertions(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 34073cd077e4..7d31250446c2 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "m_can.h"
 
@@ -1514,6 +1515,7 @@ static void m_can_stop(struct net_device *dev)
 static int m_can_close(struct net_device *dev)
 {
struct m_can_classdev *cdev = netdev_priv(dev);
+   int err;
 
netif_stop_queue(dev);
 
@@ -1536,6 +1538,10 @@ static int m_can_close(struct net_device *dev)
close_candev(dev);
can_led_event(dev, CAN_LED_EVENT_STOP);
 
+   err = phy_power_off(cdev->transceiver);
+   if (err)
+   return err;
+
return 0;
 }
 
@@ -1720,6 +1726,10 @@ static int m_can_open(struct net_device *dev)
struct m_can_classdev *cdev = netdev_priv(dev);
int err;
 
+   err = phy_power_on(cdev->transceiver);
+   if (err)
+   return err;
+
err = m_can_clk_start(cdev);
if (err)
return err;
diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h
index ace071c3e58c..38cad068abad 100644
--- a/drivers/net/can/m_can/m_can.h
+++ b/drivers/net/can/m_can/m_can.h
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* m_can lec values */
 enum m_can_lec_type {
@@ -82,6 +83,7 @@ struct m_can_classdev {
struct workqueue_struct *tx_wq;
struct work_struct tx_work;
struct sk_buff *tx_skb;
+   struct phy *transceiver;
 
struct can_bittiming_const *bit_timing;
struct can_bittiming_const *data_timing;
diff --git a/drivers/net/can/m_can/m_can_platform.c 
b/drivers/net/can/m_can/m_can_platform.c
index 599de0e08cd7..006e13ee7cd7 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -6,6 +6,7 @@
 // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
 
 #include 
+#include 
 
 #include "m_can.h"
 
@@ -67,6 +68,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
struct resource *res;
void __iomem *addr;
void __iomem *mram_addr;
+   struct phy *transceiver;
int irq, ret = 0;
 
mcan_class = m_can_class_allocate_dev(>dev,
@@ -101,6 +103,16 @@ static int m_can_plat_probe(struct platform_device *pdev)
goto probe_fail;
}
 
+   transceiver = devm_of_phy_optional_get_by_index(>dev, 
pdev->dev.of_node, 0);
+   if (IS_ERR(transceiver)) {
+   ret = PTR_ERR(transceiver);
+   dev_err(>dev, "error while getting phy, err=%d\n", ret);
+   return ret;
+   }
+
+   if (transceiver)
+   priv->cdev.can.bitrate_max = transceiver->attrs.max_link_rate;
+
priv->base = addr;
priv->mram_base = mram_addr;
 
@@ -108,6 +120,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
mcan_class->pm_clock_support = 1;
mcan_class->can.clock.freq = clk_get_rate(mcan_class->cclk);
mcan_class->dev = >dev;
+   mcan_class->transceiver = transceiver;
 
mcan_class->ops = _can_plat_ops;
 
-- 
2.17.1



[PATCH 1/2] dt-bindings: net: can: Document transceiver implementation as phy

2021-04-15 Thread Aswath Govindraju
From: Faiz Abbas 

Some transceivers need a configuration step (for example, pulling the
standby or enable lines) for them to start sending messages. The
transceiver can be implemented as a phy with the configuration done in the
phy driver. The bit rate limitation can the be obtained by the driver using
the phy node.

Document the above implementation in the bosch mcan bindings

Signed-off-by: Faiz Abbas 
Signed-off-by: Aswath Govindraju 
---
 Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml 
b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
index 798fa5fb7bb2..25f74db46bae 100644
--- a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
+++ b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
@@ -109,6 +109,9 @@ properties:
   can-transceiver:
 $ref: can-transceiver.yaml#
 
+  phys:
+maxItems: 1
+
 required:
   - compatible
   - reg
-- 
2.17.1



[PATCH 0/2] MCAN: Add support for implementing transceiver as a phy

2021-04-15 Thread Aswath Govindraju
The following series of patches add support for implementing the
transceiver as a phy of m_can_platform driver.

TCAN1042 has a standby signal that needs to be pulled high for
sending/receiving messages[1]. TCAN1043 has a enable signal along with
standby signal that needs to be pulled up for sending/receiving
messages[2], and other combinations of the two lines can be used to put the
transceiver in different states to reduce power consumption. On boards
like the AM654-idk and J721e-evm these signals are controlled using gpios.

These gpios are set in phy driver, and the transceiver can be put in
different states using phy API. The phy driver is added in the series [3].

[1] - https://www.ti.com/lit/ds/symlink/tcan1042h.pdf
[2] - https://www.ti.com/lit/ds/symlink/tcan1043-q1.pdf
[3] - https://lore.kernel.org/patchwork/project/lkml/list/?series=495365

Faiz Abbas (2):
  dt-bindings: net: can: Document transceiver implementation as phy
  can: m_can: Add support for transceiver as phy

 .../devicetree/bindings/net/can/bosch,m_can.yaml|  3 +++
 drivers/net/can/m_can/m_can.c   | 10 ++
 drivers/net/can/m_can/m_can.h   |  2 ++
 drivers/net/can/m_can/m_can_platform.c  | 13 +
 4 files changed, 28 insertions(+)

-- 
2.17.1



[PATCH v3 3/4] dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers

2021-04-15 Thread Aswath Govindraju
Add binding documentation for TI TCAN104x CAN transceivers.

Signed-off-by: Aswath Govindraju 
---
 .../bindings/phy/ti,tcan104x-can.yaml | 56 +++
 MAINTAINERS   |  1 +
 2 files changed, 57 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml

diff --git a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml 
b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
new file mode 100644
index ..4643b979930a
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/phy/ti,tcan104x-can.yaml#;
+$schema: "http://devicetree.org/meta-schemas/core.yaml#;
+
+title: TCAN104x CAN TRANSCEIVER PHY
+
+maintainers:
+  - Aswath Govindraju 
+
+properties:
+  $nodename:
+pattern: "^tcan104x-phy"
+
+  compatible:
+enum:
+  - ti,tcan1042
+  - ti,tcan1043
+
+  '#phy-cells':
+const: 0
+
+  standby-gpios:
+description:
+  gpio node to toggle standby signal on transceiver
+maxItems: 1
+
+  enable-gpios:
+description:
+  gpio node to toggle enable signal on transceiver
+maxItems: 1
+
+  max-bitrate:
+$ref: /schemas/types.yaml#/definitions/uint32
+description:
+  max bit rate supported in bps
+minimum: 1
+
+required:
+  - compatible
+  - '#phy-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+transceiver1: tcan104x-phy {
+  compatible = "ti,tcan1043";
+  #phy-cells = <0>;
+  max-bitrate = <500>;
+  standby-gpios = <_gpio1 16 GPIO_ACTIVE_LOW>;
+  enable-gpios = <_gpio1 67 GPIO_ACTIVE_HIGH>;
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index 84ef96a444c3..e666d33af10d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4046,6 +4046,7 @@ W:https://github.com/linux-can
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git
 F: Documentation/devicetree/bindings/net/can/
+F: Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
 F: drivers/net/can/
 F: include/linux/can/bittiming.h
 F: include/linux/can/dev.h
-- 
2.17.1



[PATCH v3 4/4] phy: phy-can-transceiver: Add support for generic CAN transceiver driver

2021-04-15 Thread Aswath Govindraju
The driver adds support for generic CAN transceivers. Currently
the modes supported by this driver are standby and normal modes for TI
TCAN1042 and TCAN1043 CAN transceivers.

The transceiver is modelled as a phy with pins controlled by gpios, to put
the transceiver in various device functional modes. It also gets the phy
attribute max_link_rate for the usage of CAN drivers.

Signed-off-by: Aswath Govindraju 
---
 MAINTAINERS   |   1 +
 drivers/phy/Kconfig   |   9 ++
 drivers/phy/Makefile  |   1 +
 drivers/phy/phy-can-transceiver.c | 146 ++
 4 files changed, 157 insertions(+)
 create mode 100644 drivers/phy/phy-can-transceiver.c

diff --git a/MAINTAINERS b/MAINTAINERS
index e666d33af10d..4e868f2a97c7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4048,6 +4048,7 @@ T:git 
git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git
 F: Documentation/devicetree/bindings/net/can/
 F: Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
 F: drivers/net/can/
+F: drivers/phy/phy-can-transceiver.c
 F: include/linux/can/bittiming.h
 F: include/linux/can/dev.h
 F: include/linux/can/led.h
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 54c1f2f0985f..51902b629fc6 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -61,6 +61,15 @@ config USB_LGM_PHY
  interface to interact with USB GEN-II and USB 3.x PHY that is part
  of the Intel network SOC.
 
+config PHY_CAN_TRANSCEIVER
+   tristate "CAN transceiver PHY"
+   select GENERIC_PHY
+   help
+ This option enables support for CAN transceivers as a PHY. This
+ driver provides function for putting the transceivers in various
+ functional modes using gpios and sets the attribute max link
+ rate, for mcan drivers.
+
 source "drivers/phy/allwinner/Kconfig"
 source "drivers/phy/amlogic/Kconfig"
 source "drivers/phy/broadcom/Kconfig"
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index adac1b1a39d1..01e9efffc726 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -5,6 +5,7 @@
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
 obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY)+= phy-core-mipi-dphy.o
+obj-$(CONFIG_PHY_CAN_TRANSCEIVER)  += phy-can-transceiver.o
 obj-$(CONFIG_PHY_LPC18XX_USB_OTG)  += phy-lpc18xx-usb-otg.o
 obj-$(CONFIG_PHY_XGENE)+= phy-xgene.o
 obj-$(CONFIG_PHY_PISTACHIO_USB)+= phy-pistachio-usb.o
diff --git a/drivers/phy/phy-can-transceiver.c 
b/drivers/phy/phy-can-transceiver.c
new file mode 100644
index ..c24aa2eab9e4
--- /dev/null
+++ b/drivers/phy/phy-can-transceiver.c
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * phy-can-transceiver.c - phy driver for CAN transceivers
+ *
+ * Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com
+ *
+ */
+#include
+#include
+#include
+#include
+#include
+
+struct can_transceiver_data {
+   u32 flags;
+#define CAN_TRANSCEIVER_STB_PRESENTBIT(0)
+#define CAN_TRANSCEIVER_EN_PRESENT BIT(1)
+};
+
+struct can_transceiver_phy {
+   struct phy *generic_phy;
+   struct gpio_desc *standby_gpio;
+   struct gpio_desc *enable_gpio;
+};
+
+/* Power on function */
+static int can_transceiver_phy_power_on(struct phy *phy)
+{
+   struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
+
+   if (can_transceiver_phy->standby_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
+   if (can_transceiver_phy->enable_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1);
+
+   return 0;
+}
+
+/* Power off function */
+static int can_transceiver_phy_power_off(struct phy *phy)
+{
+   struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
+
+   if (can_transceiver_phy->standby_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1);
+   if (can_transceiver_phy->enable_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 0);
+
+   return 0;
+}
+
+static const struct phy_ops can_transceiver_phy_ops = {
+   .power_on   = can_transceiver_phy_power_on,
+   .power_off  = can_transceiver_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
+static const struct can_transceiver_data tcan1042_drvdata = {
+   .flags = CAN_TRANSCEIVER_STB_PRESENT,
+};
+
+static const struct can_transceiver_data tcan1043_drvdata = {
+   .flags = CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_EN_PRESENT,
+};
+
+static const struct of_device_id can_transceiver_phy_ids[] = {
+   {
+   .compatible = "ti,tcan1042",
+   .data = _drvdata
+   },
+   {
+   .compatible = "ti,tcan1043",
+   .data = 

[PATCH v3 2/4] phy: Add API for devm_of_phy_optional_get_by_index

2021-04-15 Thread Aswath Govindraju
Add API for devm_of_phy_optional_get_by_index, to obtain a reference to an
optional phy by index.

Signed-off-by: Aswath Govindraju 
---
 drivers/phy/phy-core.c  | 26 ++
 include/linux/phy/phy.h |  2 ++
 2 files changed, 28 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index ccb575b13777..bf06d4e0ede2 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -839,6 +839,32 @@ struct phy *devm_of_phy_get(struct device *dev, struct 
device_node *np,
 }
 EXPORT_SYMBOL_GPL(devm_of_phy_get);
 
+/**
+ * devm_of_phy_optional_get_by_index() - lookup and obtain a reference to an 
optional phy by index.
+ * @dev: device that requests this phy
+ * @np: node containing the phy
+ * @index: index of the phy
+ *
+ * Gets the phy using _of_phy_get(), then gets a refcount to it,
+ * and associates a device with it using devres. On driver detach,
+ * release function is invoked on the devres data, then,
+ * devres data is freed. This differs to devm_of_phy_get_by_index() in
+ * that if the phy does not exist, it is not considered an error and
+ * -ENODEV will not be returned. Instead the NULL phy is returned,
+ * which can be passed to all other phy consumer calls.
+ */
+struct phy *devm_of_phy_optional_get_by_index(struct device *dev, struct 
device_node *np,
+ int index)
+{
+   struct phy *phy = devm_of_phy_get_by_index(dev, np, index);
+
+   if (PTR_ERR(phy) == -ENODEV)
+   phy = NULL;
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_optional_get_by_index);
+
 /**
  * devm_of_phy_get_by_index() - lookup and obtain a reference to a phy by 
index.
  * @dev: device that requests this phy
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index f3286f4cd306..c5f32b4fadd6 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -253,6 +253,8 @@ struct phy *devm_of_phy_get(struct device *dev, struct 
device_node *np,
const char *con_id);
 struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node 
*np,
 int index);
+struct phy *devm_of_phy_optional_get_by_index(struct device *dev, struct 
device_node *np,
+ int index);
 void of_phy_put(struct phy *phy);
 void phy_put(struct device *dev, struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
-- 
2.17.1



[PATCH v3 0/4] CAN TRANSCEIVER: Add support for CAN transceivers

2021-04-15 Thread Aswath Govindraju
The following series of patches add support for CAN transceivers.

TCAN1042 has a standby signal that needs to be pulled high for
sending/receiving messages[1]. TCAN1043 has a enable signal along with
standby signal that needs to be pulled up for sending/receiving
messages[2], and other combinations of the two lines can be used to put the
transceiver in different states to reduce power consumption. On boards
like the AM654-idk and J721e-evm these signals are controlled using gpios.

Patch 1 rewords the comment that restricts max_link_rate attribute to have
units of Mbps.

Patch 2 adds an API for devm_of_phy_optional_get_by_index

Patch 3 models the transceiver as a phy device tree node with properties
for max bit rate supported, gpio properties for indicating gpio pin numbers
to which standby and enable signals are connected.

Patch 4 adds a generic driver to support CAN transceivers.

changes since v2:
- dropped 5 and 6 patches and to be sent via linux-can-next
- added static keyword for can_transceiver_phy_probe()
- changed enable gpio example to active high in patch 3
- Rearranged the file names in alphabetical order in Makefile
  and MAINTAINERS file

changes since v1:
- Added patch 1 (in v2) that rewords the comment that restrict
  max_link_rate attribute to have units of Mbps.
- Added patch 2 (in v2) that adds an API for
  devm_of_phy_optional_get_by_index
- Patch 1 (in v1)
  - updated MAINTAINERS file
- Patch 2 (in v1)
  - replaced m_can with CAN to make the driver independent of CAN driver
  - Added prefix CAN_TRANSCEIVER for EN_PRESENT and STB_PRESENT
  - Added new line before return statements in power_on() and power_off
  - Added error handling patch for devm_kzalloc()
  - used the max_link_rate attribute directly instead of dividing it by
100
  - removed the spaces before GPIOD_OUT_LOW in devm_gpiod_get()
  - Corrected requested value for standby-gpios to GPIOD_OUT_HIGH
  - Updated MAINTAINERS file
- Patch 3 (in v1)
  - replaced minItems with maxItems
  - Removed phy-names property as there is only one phy
- Patch 4 (in v1)
  - replaced dev_warn with dev_info when no transceiver is found
  - Added struct phy * field in m_can_classdev struct
  - moved phy_power_on and phy_power_off to m_can_open and m_can_close
respectively
  - Moved the check for max_bit_rate to generice transceiver driver

[1] - https://www.ti.com/lit/ds/symlink/tcan1042h.pdf
[2] - https://www.ti.com/lit/ds/symlink/tcan1043-q1.pdf

Aswath Govindraju (4):
  phy: core: Reword the comment specifying the units of max_link_rate to
be Mbps
  phy: Add API for devm_of_phy_optional_get_by_index
  dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers
  phy: phy-can-transceiver: Add support for generic CAN transceiver
driver

 .../bindings/phy/ti,tcan104x-can.yaml |  56 +++
 MAINTAINERS   |   2 +
 drivers/phy/Kconfig   |   9 ++
 drivers/phy/Makefile  |   1 +
 drivers/phy/phy-can-transceiver.c | 146 ++
 drivers/phy/phy-core.c|  26 
 include/linux/phy/phy.h   |   4 +-
 7 files changed, 243 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
 create mode 100644 drivers/phy/phy-can-transceiver.c

-- 
2.17.1



[PATCH v3 1/4] phy: core: Reword the comment specifying the units of max_link_rate to be Mbps

2021-04-15 Thread Aswath Govindraju
In some subsystems (eg. CAN, SPI), the max link rate supported can be less
than 1 Mbps and if the unit for max_link_rate is Mbps then it can't be
used. Therefore, leave the decision of units to be used, to the producer
and consumer.

Signed-off-by: Aswath Govindraju 
---
 include/linux/phy/phy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 0ed434d02196..f3286f4cd306 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -125,7 +125,7 @@ struct phy_ops {
 /**
  * struct phy_attrs - represents phy attributes
  * @bus_width: Data path width implemented by PHY
- * @max_link_rate: Maximum link rate supported by PHY (in Mbps)
+ * @max_link_rate: Maximum link rate supported by PHY (units to be decided by 
producer and consumer)
  * @mode: PHY mode
  */
 struct phy_attrs {
-- 
2.17.1



Re: [PATCH v2 3/6] dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers

2021-04-15 Thread Aswath Govindraju
Hi Marc,

On 15/04/21 1:08 pm, Marc Kleine-Budde wrote:
> On 15.04.2021 11:57:20, Aswath Govindraju wrote:
>> Hi Marc,
>>
>> On 14/04/21 9:03 pm, Marc Kleine-Budde wrote:
>>> On 14.04.2021 19:35:18, Aswath Govindraju wrote:
>>>> Add binding documentation for TI TCAN104x CAN transceivers.
>>>>
>>>> Signed-off-by: Aswath Govindraju 
>>>> ---
>>>>  .../bindings/phy/ti,tcan104x-can.yaml | 56 +++
>>>>  MAINTAINERS   |  1 +
>>>>  2 files changed, 57 insertions(+)
>>>>  create mode 100644 
>>>> Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml 
>>>> b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
>>>> new file mode 100644
>>>> index ..4abfc30a97d0
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
>>>> @@ -0,0 +1,56 @@
>>>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>>>> +%YAML 1.2
>>>> +---
>>>> +$id: "http://devicetree.org/schemas/phy/ti,tcan104x-can.yaml#;
>>>> +$schema: "http://devicetree.org/meta-schemas/core.yaml#;
>>>> +
>>>> +title: TCAN104x CAN TRANSCEIVER PHY
>>>> +
>>>> +maintainers:
>>>> +  - Aswath Govindraju 
> 
> Can you create a maintainers entry for this file with your address?

I don't see this being done for other phy yamls in the
Documentation/devicetree/bindings/phy folder. Also,
scripts/get_maintainer.pl is giving the names of maintainers after
reading the yaml files too.

Thanks,
Aswath

> 
>>>> +
>>>> +properties:
>>>> +  $nodename:
>>>> +pattern: "^tcan104x-phy"
>>>> +
>>>> +  compatible:
>>>> +enum:
>>>> +  - ti,tcan1042
>>>> +  - ti,tcan1043
>>>
>>> Can you ensure that the 1042 has only the standby gpio and the 1043 has 
>>> both?
>>>
>>
>> In the driver, it is the way the flags have been set for ti,tcan1042 and
>> ti,tcan1043.
> 
> I was wondering if we would enforce in the DT the 1042 has exactly one
> the standby GPIO and the 1043 has exactly the standby and the enable
> GPIO.
> 
> On the other hand the HW might have pulled one or the other pin high or
> low and only one of the pins is connected to a GPIO.
> 
>>>> +
>>>> +  '#phy-cells':
>>>> +const: 0
>>>> +
>>>> +  standby-gpios:
>>>> +description:
>>>> +  gpio node to toggle standby signal on transceiver
>>>> +maxItems: 1
>>>> +
>>>> +  enable-gpios:
>>>> +description:
>>>> +  gpio node to toggle enable signal on transceiver
>>>> +maxItems: 1
>>>> +
>>>> +  max-bitrate:
>>>> +$ref: /schemas/types.yaml#/definitions/uint32
>>>> +description:
>>>> +  max bit rate supported in bps
>>>> +minimum: 1
>>>> +
>>>> +required:
>>>> +  - compatible
>>>> +  - '#phy-cells'
>>>> +
>>>> +additionalProperties: false
>>>> +
>>>> +examples:
>>>> +  - |
>>>> +#include 
>>>> +
>>>> +transceiver1: tcan104x-phy {
>>>> +  compatible = "ti,tcan1043";
>>>> +  #phy-cells = <0>;
>>>> +  max-bitrate = <500>;
>>>> +  standby-gpios = <_gpio1 16 GPIO_ACTIVE_LOW>;
>>>> +  enable-gpios = <_gpio1 67 GPIO_ACTIVE_LOW>;
>>>
>>> AFAICS the enable gpio is active high.
>>>
>>
>> I will correct this in the respin.
> 
> Marc
> 



Re: [PATCH v2 3/6] dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers

2021-04-15 Thread Aswath Govindraju
Hi Marc,

On 14/04/21 9:03 pm, Marc Kleine-Budde wrote:
> On 14.04.2021 19:35:18, Aswath Govindraju wrote:
>> Add binding documentation for TI TCAN104x CAN transceivers.
>>
>> Signed-off-by: Aswath Govindraju 
>> ---
>>  .../bindings/phy/ti,tcan104x-can.yaml | 56 +++
>>  MAINTAINERS   |  1 +
>>  2 files changed, 57 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml 
>> b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
>> new file mode 100644
>> index ..4abfc30a97d0
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
>> @@ -0,0 +1,56 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: "http://devicetree.org/schemas/phy/ti,tcan104x-can.yaml#;
>> +$schema: "http://devicetree.org/meta-schemas/core.yaml#;
>> +
>> +title: TCAN104x CAN TRANSCEIVER PHY
>> +
>> +maintainers:
>> +  - Aswath Govindraju 
>> +
>> +properties:
>> +  $nodename:
>> +pattern: "^tcan104x-phy"
>> +
>> +  compatible:
>> +enum:
>> +  - ti,tcan1042
>> +  - ti,tcan1043
> 
> Can you ensure that the 1042 has only the standby gpio and the 1043 has both?
> 

In the driver, it is the way the flags have been set for ti,tcan1042 and
ti,tcan1043.

>> +
>> +  '#phy-cells':
>> +const: 0
>> +
>> +  standby-gpios:
>> +description:
>> +  gpio node to toggle standby signal on transceiver
>> +maxItems: 1
>> +
>> +  enable-gpios:
>> +description:
>> +  gpio node to toggle enable signal on transceiver
>> +maxItems: 1
>> +
>> +  max-bitrate:
>> +$ref: /schemas/types.yaml#/definitions/uint32
>> +description:
>> +  max bit rate supported in bps
>> +minimum: 1
>> +
>> +required:
>> +  - compatible
>> +  - '#phy-cells'
>> +
>> +additionalProperties: false
>> +
>> +examples:
>> +  - |
>> +#include 
>> +
>> +transceiver1: tcan104x-phy {
>> +  compatible = "ti,tcan1043";
>> +  #phy-cells = <0>;
>> +  max-bitrate = <500>;
>> +  standby-gpios = <_gpio1 16 GPIO_ACTIVE_LOW>;
>> +  enable-gpios = <_gpio1 67 GPIO_ACTIVE_LOW>;
> 
> AFAICS the enable gpio is active high.
> 

I will correct this in the respin.

Thanks,
Aswath

> Marc
> 



[PATCH v2 6/6] can: m_can: Add support for transceiver as phy

2021-04-14 Thread Aswath Govindraju
From: Faiz Abbas 

Add support for implementing transceiver node as phy. The max_bitrate is
obtained by getting a phy attribute.

Signed-off-by: Faiz Abbas 
Signed-off-by: Aswath Govindraju 
---
 drivers/net/can/m_can/m_can.c  | 18 ++
 drivers/net/can/m_can/m_can.h  |  2 ++
 drivers/net/can/m_can/m_can_platform.c | 15 +++
 3 files changed, 35 insertions(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 34073cd077e4..4807a1f69cc7 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "m_can.h"
 
@@ -1514,6 +1515,7 @@ static void m_can_stop(struct net_device *dev)
 static int m_can_close(struct net_device *dev)
 {
struct m_can_classdev *cdev = netdev_priv(dev);
+   int err;
 
netif_stop_queue(dev);
 
@@ -1536,6 +1538,14 @@ static int m_can_close(struct net_device *dev)
close_candev(dev);
can_led_event(dev, CAN_LED_EVENT_STOP);
 
+   if (cdev->transceiver) {
+   err = phy_power_off(cdev->transceiver);
+   if (err) {
+   netdev_err(dev, "error powering off phy, err=%d\n", 
err);
+   return err;
+   }
+   }
+
return 0;
 }
 
@@ -1720,6 +1730,14 @@ static int m_can_open(struct net_device *dev)
struct m_can_classdev *cdev = netdev_priv(dev);
int err;
 
+   if (cdev->transceiver) {
+   err = phy_power_on(cdev->transceiver);
+   if (err) {
+   netdev_err(dev, "error powering on phy, err=%d\n", err);
+   return err;
+   }
+   }
+
err = m_can_clk_start(cdev);
if (err)
return err;
diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h
index ace071c3e58c..38cad068abad 100644
--- a/drivers/net/can/m_can/m_can.h
+++ b/drivers/net/can/m_can/m_can.h
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* m_can lec values */
 enum m_can_lec_type {
@@ -82,6 +83,7 @@ struct m_can_classdev {
struct workqueue_struct *tx_wq;
struct work_struct tx_work;
struct sk_buff *tx_skb;
+   struct phy *transceiver;
 
struct can_bittiming_const *bit_timing;
struct can_bittiming_const *data_timing;
diff --git a/drivers/net/can/m_can/m_can_platform.c 
b/drivers/net/can/m_can/m_can_platform.c
index 599de0e08cd7..566ba25fb186 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -6,6 +6,7 @@
 // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
 
 #include 
+#include 
 
 #include "m_can.h"
 
@@ -67,6 +68,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
struct resource *res;
void __iomem *addr;
void __iomem *mram_addr;
+   struct phy *transceiver;
int irq, ret = 0;
 
mcan_class = m_can_class_allocate_dev(>dev,
@@ -101,6 +103,18 @@ static int m_can_plat_probe(struct platform_device *pdev)
goto probe_fail;
}
 
+   transceiver = devm_of_phy_optional_get_by_index(>dev, 
pdev->dev.of_node, 0);
+   if (IS_ERR(transceiver)) {
+   ret = PTR_ERR(transceiver);
+   dev_err(>dev, "error while getting phy, err=%d\n", ret);
+   return ret;
+   }
+
+   if (!transceiver)
+   dev_info(>dev, "No transceiver phy found\n");
+   else
+   priv->cdev.can.bitrate_max = transceiver->attrs.max_link_rate;
+
priv->base = addr;
priv->mram_base = mram_addr;
 
@@ -108,6 +122,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
mcan_class->pm_clock_support = 1;
mcan_class->can.clock.freq = clk_get_rate(mcan_class->cclk);
mcan_class->dev = >dev;
+   mcan_class->transceiver = transceiver;
 
mcan_class->ops = _can_plat_ops;
 
-- 
2.17.1



[PATCH v2 5/6] dt-bindings: net: can: Document transceiver implementation as phy

2021-04-14 Thread Aswath Govindraju
From: Faiz Abbas 

Some transceivers need a configuration step (for example, pulling the
standby or enable lines) for them to start sending messages. The
transceiver can be implemented as a phy with the configuration done in the
phy driver. The bit rate limitation can the be obtained by the driver using
the phy node.

Document the above implementation in the bosch mcan bindings

Signed-off-by: Faiz Abbas 
Signed-off-by: Aswath Govindraju 
---
 Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml 
b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
index 798fa5fb7bb2..25f74db46bae 100644
--- a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
+++ b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
@@ -109,6 +109,9 @@ properties:
   can-transceiver:
 $ref: can-transceiver.yaml#
 
+  phys:
+maxItems: 1
+
 required:
   - compatible
   - reg
-- 
2.17.1



[PATCH v2 4/6] phy: phy-can-transceiver: Add support for generic CAN transceiver driver

2021-04-14 Thread Aswath Govindraju
The driver adds support for generic CAN transceivers. Currently
the modes supported by this driver are standby and normal modes for TI
TCAN1042 and TCAN1043 CAN transceivers.

The transceiver is modelled as a phy with pins controlled by gpios, to put
the transceiver in various device functional modes. It also gets the phy
attribute max_link_rate for the usage of CAN drivers.

Signed-off-by: Aswath Govindraju 
---
 MAINTAINERS   |   1 +
 drivers/phy/Kconfig   |   9 ++
 drivers/phy/Makefile  |   1 +
 drivers/phy/phy-can-transceiver.c | 146 ++
 4 files changed, 157 insertions(+)
 create mode 100644 drivers/phy/phy-can-transceiver.c

diff --git a/MAINTAINERS b/MAINTAINERS
index e666d33af10d..70e1438c372d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4047,6 +4047,7 @@ T:git 
git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git
 F: Documentation/devicetree/bindings/net/can/
 F: Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
+F: drivers/phy/phy-can-transceiver.c
 F: drivers/net/can/
 F: include/linux/can/bittiming.h
 F: include/linux/can/dev.h
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 54c1f2f0985f..51902b629fc6 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -61,6 +61,15 @@ config USB_LGM_PHY
  interface to interact with USB GEN-II and USB 3.x PHY that is part
  of the Intel network SOC.
 
+config PHY_CAN_TRANSCEIVER
+   tristate "CAN transceiver PHY"
+   select GENERIC_PHY
+   help
+ This option enables support for CAN transceivers as a PHY. This
+ driver provides function for putting the transceivers in various
+ functional modes using gpios and sets the attribute max link
+ rate, for mcan drivers.
+
 source "drivers/phy/allwinner/Kconfig"
 source "drivers/phy/amlogic/Kconfig"
 source "drivers/phy/broadcom/Kconfig"
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index adac1b1a39d1..9c66101c9605 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_PHY_LPC18XX_USB_OTG)   += phy-lpc18xx-usb-otg.o
 obj-$(CONFIG_PHY_XGENE)+= phy-xgene.o
 obj-$(CONFIG_PHY_PISTACHIO_USB)+= phy-pistachio-usb.o
 obj-$(CONFIG_USB_LGM_PHY)  += phy-lgm-usb.o
+obj-$(CONFIG_PHY_CAN_TRANSCEIVER)  += phy-can-transceiver.o
 obj-y  += allwinner/   \
   amlogic/ \
   broadcom/\
diff --git a/drivers/phy/phy-can-transceiver.c 
b/drivers/phy/phy-can-transceiver.c
new file mode 100644
index ..f2976c1f4d0f
--- /dev/null
+++ b/drivers/phy/phy-can-transceiver.c
@@ -0,0 +1,146 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * phy-can-transceiver.c - phy driver for CAN transceivers
+ *
+ * Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com
+ *
+ */
+#include
+#include
+#include
+#include
+#include
+
+struct can_transceiver_data {
+   u32 flags;
+#define CAN_TRANSCEIVER_STB_PRESENTBIT(0)
+#define CAN_TRANSCEIVER_EN_PRESENT BIT(1)
+};
+
+struct can_transceiver_phy {
+   struct phy *generic_phy;
+   struct gpio_desc *standby_gpio;
+   struct gpio_desc *enable_gpio;
+};
+
+/* Power on function */
+static int can_transceiver_phy_power_on(struct phy *phy)
+{
+   struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
+
+   if (can_transceiver_phy->standby_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
+   if (can_transceiver_phy->enable_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1);
+
+   return 0;
+}
+
+/* Power off function */
+static int can_transceiver_phy_power_off(struct phy *phy)
+{
+   struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
+
+   if (can_transceiver_phy->standby_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1);
+   if (can_transceiver_phy->enable_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 0);
+
+   return 0;
+}
+
+static const struct phy_ops can_transceiver_phy_ops = {
+   .power_on   = can_transceiver_phy_power_on,
+   .power_off  = can_transceiver_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
+static const struct can_transceiver_data tcan1042_drvdata = {
+   .flags = CAN_TRANSCEIVER_STB_PRESENT,
+};
+
+static const struct can_transceiver_data tcan1043_drvdata = {
+   .flags = CAN_TRANSCEIVER_STB_PRESENT | CAN_TRANSCEIVER_EN_PRESENT,
+};
+
+static const struct of_device_id can_transceiver_phy_ids[] = {
+   {
+

[PATCH v2 1/6] phy: core: Reword the comment specifying the units of max_link_rate to be Mbps

2021-04-14 Thread Aswath Govindraju
In some subsystems (eg. CAN, SPI), the max link rate supported can be less
than 1 Mbps and if the unit for max_link_rate is Mbps then it can't be
used. Therefore, leave the decision of units to be used, to the producer
and consumer.

Signed-off-by: Aswath Govindraju 
---
 include/linux/phy/phy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 0ed434d02196..f3286f4cd306 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -125,7 +125,7 @@ struct phy_ops {
 /**
  * struct phy_attrs - represents phy attributes
  * @bus_width: Data path width implemented by PHY
- * @max_link_rate: Maximum link rate supported by PHY (in Mbps)
+ * @max_link_rate: Maximum link rate supported by PHY (units to be decided by 
producer and consumer)
  * @mode: PHY mode
  */
 struct phy_attrs {
-- 
2.17.1



[PATCH v2 3/6] dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers

2021-04-14 Thread Aswath Govindraju
Add binding documentation for TI TCAN104x CAN transceivers.

Signed-off-by: Aswath Govindraju 
---
 .../bindings/phy/ti,tcan104x-can.yaml | 56 +++
 MAINTAINERS   |  1 +
 2 files changed, 57 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml

diff --git a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml 
b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
new file mode 100644
index ..4abfc30a97d0
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/phy/ti,tcan104x-can.yaml#;
+$schema: "http://devicetree.org/meta-schemas/core.yaml#;
+
+title: TCAN104x CAN TRANSCEIVER PHY
+
+maintainers:
+  - Aswath Govindraju 
+
+properties:
+  $nodename:
+pattern: "^tcan104x-phy"
+
+  compatible:
+enum:
+  - ti,tcan1042
+  - ti,tcan1043
+
+  '#phy-cells':
+const: 0
+
+  standby-gpios:
+description:
+  gpio node to toggle standby signal on transceiver
+maxItems: 1
+
+  enable-gpios:
+description:
+  gpio node to toggle enable signal on transceiver
+maxItems: 1
+
+  max-bitrate:
+$ref: /schemas/types.yaml#/definitions/uint32
+description:
+  max bit rate supported in bps
+minimum: 1
+
+required:
+  - compatible
+  - '#phy-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+transceiver1: tcan104x-phy {
+  compatible = "ti,tcan1043";
+  #phy-cells = <0>;
+  max-bitrate = <500>;
+  standby-gpios = <_gpio1 16 GPIO_ACTIVE_LOW>;
+  enable-gpios = <_gpio1 67 GPIO_ACTIVE_LOW>;
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index 84ef96a444c3..e666d33af10d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4046,6 +4046,7 @@ W:https://github.com/linux-can
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git
 F: Documentation/devicetree/bindings/net/can/
+F: Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
 F: drivers/net/can/
 F: include/linux/can/bittiming.h
 F: include/linux/can/dev.h
-- 
2.17.1



[PATCH v2 2/6] phy: Add API for devm_of_phy_optional_get_by_index

2021-04-14 Thread Aswath Govindraju
Add API for devm_of_phy_optional_get_by_index, to obtain a reference to an
optional phy by index.

Signed-off-by: Aswath Govindraju 
---
 drivers/phy/phy-core.c  | 26 ++
 include/linux/phy/phy.h |  2 ++
 2 files changed, 28 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index ccb575b13777..bf06d4e0ede2 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -839,6 +839,32 @@ struct phy *devm_of_phy_get(struct device *dev, struct 
device_node *np,
 }
 EXPORT_SYMBOL_GPL(devm_of_phy_get);
 
+/**
+ * devm_of_phy_optional_get_by_index() - lookup and obtain a reference to an 
optional phy by index.
+ * @dev: device that requests this phy
+ * @np: node containing the phy
+ * @index: index of the phy
+ *
+ * Gets the phy using _of_phy_get(), then gets a refcount to it,
+ * and associates a device with it using devres. On driver detach,
+ * release function is invoked on the devres data, then,
+ * devres data is freed. This differs to devm_of_phy_get_by_index() in
+ * that if the phy does not exist, it is not considered an error and
+ * -ENODEV will not be returned. Instead the NULL phy is returned,
+ * which can be passed to all other phy consumer calls.
+ */
+struct phy *devm_of_phy_optional_get_by_index(struct device *dev, struct 
device_node *np,
+ int index)
+{
+   struct phy *phy = devm_of_phy_get_by_index(dev, np, index);
+
+   if (PTR_ERR(phy) == -ENODEV)
+   phy = NULL;
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_optional_get_by_index);
+
 /**
  * devm_of_phy_get_by_index() - lookup and obtain a reference to a phy by 
index.
  * @dev: device that requests this phy
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index f3286f4cd306..c5f32b4fadd6 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -253,6 +253,8 @@ struct phy *devm_of_phy_get(struct device *dev, struct 
device_node *np,
const char *con_id);
 struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node 
*np,
 int index);
+struct phy *devm_of_phy_optional_get_by_index(struct device *dev, struct 
device_node *np,
+ int index);
 void of_phy_put(struct phy *phy);
 void phy_put(struct device *dev, struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
-- 
2.17.1



[PATCH v2 0/6] CAN TRANSCEIVER: Add support for CAN transceivers

2021-04-14 Thread Aswath Govindraju
The following series of patches add support for CAN transceivers.

TCAN1042 has a standby signal that needs to be pulled high for
sending/receiving messages[1]. TCAN1043 has a enable signal along with
standby signal that needs to be pulled up for sending/receiving
messages[2], and other combinations of the two lines can be used to put the
transceiver in different states to reduce power consumption. On boards
like the AM654-idk and J721e-evm these signals are controlled using gpios.

Patch 1 rewords the comment that restricts max_link_rate attribute to have
units of Mbps.

Patch 2 adds an API for devm_of_phy_optional_get_by_index

Patch 3 models the transceiver as a phy device tree node with properties
for max bit rate supported, gpio properties for indicating gpio pin numbers
to which standby and enable signals are connected.

Patch 4 adds a generic driver to support CAN transceivers.

Patches 5 & 6 add support for implementing the transceiver as a phy of
m_can_platform driver.

changes since v1:
- Added patch 1 (in v2) that rewords the comment that restrict
  max_link_rate attribute to have units of Mbps.
- Added patch 2 (in v2) that adds an API for
  devm_of_phy_optional_get_by_index
- Patch 1 (in v1)
  - updated MAINTAINERS file
- Patch 2 (in v1)
  - replaced m_can with CAN to make the driver independent of CAN driver
  - Added prefix CAN_TRANSCEIVER for EN_PRESENT and STB_PRESENT
  - Added new line before return statements in power_on() and power_off
  - Added error handling patch for devm_kzalloc()
  - used the max_link_rate attribute directly instead of dividing it by
100
  - removed the spaces before GPIOD_OUT_LOW in devm_gpiod_get()
  - Corrected requested value for standby-gpios to GPIOD_OUT_HIGH
  - Updated MAINTAINERS file
- Patch 3 (in v1)
  - replaced minItems with maxItems
  - Removed phy-names property as there is only one phy
- Patch 4 (in v1)
  - replaced dev_warn with dev_info when no transceiver is found
  - Added struct phy * field in m_can_classdev struct
  - moved phy_power_on and phy_power_off to m_can_open and m_can_close
respectively
  - Moved the check for max_bit_rate to generice transceiver driver

[1] - https://www.ti.com/lit/ds/symlink/tcan1042h.pdf
[2] - https://www.ti.com/lit/ds/symlink/tcan1043-q1.pdf

Aswath Govindraju (4):
  phy: core: Reword the comment specifying the units of max_link_rate to
be Mbps
  phy: Add API for devm_of_phy_optional_get_by_index
  dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers
  phy: phy-can-transceiver: Add support for generic CAN transceiver
driver

Faiz Abbas (2):
  dt-bindings: net: can: Document transceiver implementation as phy
  can: m_can: Add support for transceiver as phy

 .../bindings/net/can/bosch,m_can.yaml |   3 +
 .../bindings/phy/ti,tcan104x-can.yaml |  56 +++
 MAINTAINERS   |   2 +
 drivers/net/can/m_can/m_can.c |  18 +++
 drivers/net/can/m_can/m_can.h |   2 +
 drivers/net/can/m_can/m_can_platform.c|  15 ++
 drivers/phy/Kconfig   |   9 ++
 drivers/phy/Makefile  |   1 +
 drivers/phy/phy-can-transceiver.c | 146 ++
 drivers/phy/phy-core.c|  26 
 include/linux/phy/phy.h   |   4 +-
 11 files changed, 281 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
 create mode 100644 drivers/phy/phy-can-transceiver.c

-- 
2.17.1



Re: [PATCH 1/4] dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers

2021-04-14 Thread Aswath Govindraju
Hi Marc,

On 13/04/21 6:45 pm, Rob Herring wrote:
> On Tue, Apr 13, 2021 at 2:41 AM Marc Kleine-Budde  wrote:
>>
>> On 12.04.2021 12:49:56, Rob Herring wrote:
>>> On Mon, Apr 12, 2021 at 12:19:30PM +0200, Marc Kleine-Budde wrote:
>>>> On 4/9/21 3:40 PM, Aswath Govindraju wrote:
>>>>> Add binding documentation for TI TCAN104x CAN transceivers.
>>>>>
>>>>> Signed-off-by: Aswath Govindraju 
>>>>> ---
>>>>>  .../bindings/phy/ti,tcan104x-can.yaml | 56 +++
>>>>>  1 file changed, 56 insertions(+)
>>>>>  create mode 100644 
>>>>> Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml 
>>>>> b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
>>>>> new file mode 100644
>>>>> index ..4abfc30a97d0
>>>>> --- /dev/null
>>>>> +++ b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
>>>>> @@ -0,0 +1,56 @@
>>>>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>>>>> +%YAML 1.2
>>>>> +---
>>>>> +$id: "http://devicetree.org/schemas/phy/ti,tcan104x-can.yaml#;
>>>>> +$schema: "http://devicetree.org/meta-schemas/core.yaml#;
>>>>> +
>>>>> +title: TCAN104x CAN TRANSCEIVER PHY
>>>>> +
>>>>> +maintainers:
>>>>> +  - Aswath Govindraju 
>>>>> +
>>>>> +properties:
>>>>> +  $nodename:
>>>>> +pattern: "^tcan104x-phy"
>>>>> +
>>>>> +  compatible:
>>>>> +enum:
>>>>> +  - ti,tcan1042
>>>>> +  - ti,tcan1043
>>>>
>>>> Can you create a generic standby only and a generic standby and enable 
>>>> transceiver?
>>>
>>> As a fallback compatible fine, but no generic binding please. A generic
>>> binding can't describe any timing requirements between the 2 GPIO as
>>> well as supplies when someone wants to add those (and they will).
>>
>> Right - that makes sense.
>>

So, I need not add any new compatible strings right because as a
fallback the existing compatible strings can be used, as there are no
timing constraints on them.

Thanks,
Aswath

>>>>> +
>>>>> +  '#phy-cells':
>>>>> +const: 0
>>>>> +
>>>>> +  standby-gpios:
>>>>> +description:
>>>>> +  gpio node to toggle standby signal on transceiver
>>>>> +maxItems: 1
>>>>> +
>>>>> +  enable-gpios:
>>>>> +description:
>>>>> +  gpio node to toggle enable signal on transceiver
>>>>> +maxItems: 1
>>>>> +
>>>>> +  max-bitrate:
>>>>> +$ref: /schemas/types.yaml#/definitions/uint32
>>>>> +description:
>>>>> +  max bit rate supported in bps
>>>
>>> We already have 'max-speed' for serial devices, use that.
>>
>> There is already the neither Ethernet PHY (PHYLINK/PHYLIB) nor generic
>> PHY (GENERIC_PHY) can-transceiver binding
>> Documentation/devicetree/bindings/net/can/can-transceiver.yaml which
>> specifies max-bitrate. I don't have strong feelings whether to use
>> max-bitrate or max-speed.
> 
> Okay, max-bitrate is fine.
> 
>>
>> Speaking about Ethernet PHYs, what are to pros and cons to use the
>> generic PHY compared to the Ethernet PHY infrastructure?
> 
> For higher speed ethernet, both are used. There's the serdes phy and
> the ethernet phy with serdes phy using the generic phy binding. For
> CAN, it probably comes down to what's a better fit.
> 
> Rob
> 



Re: [PATCH 3/4] dt-bindings: net: can: Document transceiver implementation as phy

2021-04-14 Thread Aswath Govindraju
Hi Rob,

On 12/04/21 11:21 pm, Rob Herring wrote:
> On Fri, Apr 09, 2021 at 07:10:53PM +0530, Aswath Govindraju wrote:
>> From: Faiz Abbas 
>>
>> Some transceivers need a configuration step (for example, pulling the
>> standby or enable lines) for them to start sending messages. The
>> transceiver can be implemented as a phy with the configuration done in the
>> phy driver. The bit rate limitation can the be obtained by the driver using
>> the phy node.
>>
>> Document the above implementation in the bosch mcan bindings
>>
>> Signed-off-by: Faiz Abbas 
>> Signed-off-by: Aswath Govindraju 
>> ---
>>  Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 6 ++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml 
>> b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
>> index 798fa5fb7bb2..2c01899b1a3e 100644
>> --- a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
>> +++ b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
>> @@ -109,6 +109,12 @@ properties:
>>can-transceiver:
>>  $ref: can-transceiver.yaml#
>>  
>> +  phys:
>> +minItems: 1
> 
> maxItems: 1

Will add this in the respin.

> 
>> +
>> +  phy-names:
>> +const: can_transceiver
> 
> Kind of a pointless name. You don't really need a name if there's a 
> single entry.
> 

This name used by devm_phy_optional_get() in m_can driver to get the phy
data structure.

Thank you for the review.

Regards,
Aswath

>> +
>>  required:
>>- compatible
>>- reg
>> -- 
>> 2.17.1
>>



Re: [PATCH 2/4] phy: phy-can-transceiver: Add support for generic CAN transceiver driver

2021-04-14 Thread Aswath Govindraju
Hi Marc,

On 12/04/21 3:48 pm, Marc Kleine-Budde wrote:
> On 4/9/21 3:40 PM, Aswath Govindraju wrote:
>> The driver adds support for generic CAN transceivers. Currently
>> the modes supported by this driver are standby and normal modes for TI
>> TCAN1042 and TCAN1043 CAN transceivers.
>>
>> The transceiver is modelled as a phy with pins controlled by gpios, to put
>> the transceiver in various device functional modes. It also gets the phy
>> attribute max_link_rate for the usage of m_can drivers.
> 
> This driver should be independent of CAN driver, so you should not mention a
> specific driver here.
> 

I will substitute m_can with can in the respin.

>> Signed-off-by: Aswath Govindraju 
>> ---
>>  drivers/phy/Kconfig   |   9 ++
>>  drivers/phy/Makefile  |   1 +
>>  drivers/phy/phy-can-transceiver.c | 140 ++
>>  3 files changed, 150 insertions(+)
>>  create mode 100644 drivers/phy/phy-can-transceiver.c
>>
>> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
>> index 54c1f2f0985f..51902b629fc6 100644
>> --- a/drivers/phy/Kconfig
>> +++ b/drivers/phy/Kconfig
>> @@ -61,6 +61,15 @@ config USB_LGM_PHY
>>interface to interact with USB GEN-II and USB 3.x PHY that is part
>>of the Intel network SOC.
>>  
>> +config PHY_CAN_TRANSCEIVER
>> +tristate "CAN transceiver PHY"
>> +select GENERIC_PHY
>> +help
>> +  This option enables support for CAN transceivers as a PHY. This
>> +  driver provides function for putting the transceivers in various
>> +  functional modes using gpios and sets the attribute max link
>> +  rate, for mcan drivers.
>> +
>>  source "drivers/phy/allwinner/Kconfig"
>>  source "drivers/phy/amlogic/Kconfig"
>>  source "drivers/phy/broadcom/Kconfig"
>> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
>> index adac1b1a39d1..9c66101c9605 100644
>> --- a/drivers/phy/Makefile
>> +++ b/drivers/phy/Makefile
>> @@ -9,6 +9,7 @@ obj-$(CONFIG_PHY_LPC18XX_USB_OTG)+= phy-lpc18xx-usb-otg.o
>>  obj-$(CONFIG_PHY_XGENE) += phy-xgene.o
>>  obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o
>>  obj-$(CONFIG_USB_LGM_PHY)   += phy-lgm-usb.o
>> +obj-$(CONFIG_PHY_CAN_TRANSCEIVER)   += phy-can-transceiver.o
>>  obj-y   += allwinner/   \
>> amlogic/ \
>> broadcom/\
>> diff --git a/drivers/phy/phy-can-transceiver.c 
>> b/drivers/phy/phy-can-transceiver.c
>> new file mode 100644
>> index ..14496f6e1666
>> --- /dev/null
>> +++ b/drivers/phy/phy-can-transceiver.c
>> @@ -0,0 +1,140 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * phy-can-transceiver.c - phy driver for CAN transceivers
>> + *
>> + * Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com
>> + *
>> + */
>> +#include
>> +#include
>> +#include
>> +#include
>> +#include
>> +
>> +struct can_transceiver_data {
>> +u32 flags;
>> +#define STB_PRESENT BIT(0)
>> +#define EN_PRESENT  BIT(1)
> 
> please add a common prefix to the defines

I will add a common prefix(GPIO) in the respin.

> 
>> +};
>> +
>> +struct can_transceiver_phy {
>> +struct phy *generic_phy;
>> +struct gpio_desc *standby_gpio;
>> +struct gpio_desc *enable_gpio;
>> +};
>> +
>> +/* Power on function */
>> +static int can_transceiver_phy_power_on(struct phy *phy)
>> +{
>> +struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
>> +
>> +if (can_transceiver_phy->standby_gpio)
>> +gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
>> +if (can_transceiver_phy->enable_gpio)
>> +gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1);
> 
> Please add a newline before the return.
> 

Will make this change in the respin.

>> +return 0;
>> +}
>> +
>> +/* Power off function */
>> +static int can_transceiver_phy_power_off(struct phy *phy)
>> +{
>> +struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
>> +
>> +if (can_transceiver_phy->standby_gpio)
>> +gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1);
>> +if (can_transceiver_phy->enable_gpio)
>> +gpiod_set_value_c

[PATCH 4/4] can: m_can_platform: Add support for transceiver as phy

2021-04-09 Thread Aswath Govindraju
From: Faiz Abbas 

Add support for implementing transceiver node as phy. The max_bitrate is
obtained by getting a phy attribute.

Signed-off-by: Faiz Abbas 
Signed-off-by: Aswath Govindraju 
---
 drivers/net/can/m_can/m_can_platform.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/can/m_can/m_can_platform.c 
b/drivers/net/can/m_can/m_can_platform.c
index 599de0e08cd7..4a762b5a21d8 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -6,6 +6,7 @@
 // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
 
 #include 
+#include 
 
 #include "m_can.h"
 
@@ -67,7 +68,9 @@ static int m_can_plat_probe(struct platform_device *pdev)
struct resource *res;
void __iomem *addr;
void __iomem *mram_addr;
+   struct phy *transceiver;
int irq, ret = 0;
+   u32 bitrate_max;
 
mcan_class = m_can_class_allocate_dev(>dev,
  sizeof(struct m_can_plat_priv));
@@ -101,6 +104,28 @@ static int m_can_plat_probe(struct platform_device *pdev)
goto probe_fail;
}
 
+   transceiver = devm_phy_optional_get(>dev, "can_transceiver");
+   if (IS_ERR(transceiver)) {
+   ret = PTR_ERR(transceiver);
+   dev_err(>dev, "error while getting phy, err=%d\n", ret);
+   return ret;
+   }
+
+   if (!transceiver) {
+   dev_warn(>dev, "No transceiver phy found\n");
+   } else {
+   ret = phy_power_on(transceiver);
+   if (ret) {
+   dev_err(>dev, "error powering on phy, err=%d\n", 
ret);
+   return ret;
+   }
+   /* converting from Mbps to bps */
+   bitrate_max = (transceiver->attrs.max_link_rate) * 100;
+   if (!bitrate_max)
+   dev_warn(>dev, "Invalid value for transceiver max 
bitrate. Ignoring bitrate limit\n");
+   priv->cdev.can.bitrate_max = bitrate_max;
+   }
+
priv->base = addr;
priv->mram_base = mram_addr;
 
-- 
2.17.1



[PATCH 3/4] dt-bindings: net: can: Document transceiver implementation as phy

2021-04-09 Thread Aswath Govindraju
From: Faiz Abbas 

Some transceivers need a configuration step (for example, pulling the
standby or enable lines) for them to start sending messages. The
transceiver can be implemented as a phy with the configuration done in the
phy driver. The bit rate limitation can the be obtained by the driver using
the phy node.

Document the above implementation in the bosch mcan bindings

Signed-off-by: Faiz Abbas 
Signed-off-by: Aswath Govindraju 
---
 Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml 
b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
index 798fa5fb7bb2..2c01899b1a3e 100644
--- a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
+++ b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
@@ -109,6 +109,12 @@ properties:
   can-transceiver:
 $ref: can-transceiver.yaml#
 
+  phys:
+minItems: 1
+
+  phy-names:
+const: can_transceiver
+
 required:
   - compatible
   - reg
-- 
2.17.1



[PATCH 1/4] dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers

2021-04-09 Thread Aswath Govindraju
Add binding documentation for TI TCAN104x CAN transceivers.

Signed-off-by: Aswath Govindraju 
---
 .../bindings/phy/ti,tcan104x-can.yaml | 56 +++
 1 file changed, 56 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml

diff --git a/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml 
b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
new file mode 100644
index ..4abfc30a97d0
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/phy/ti,tcan104x-can.yaml#;
+$schema: "http://devicetree.org/meta-schemas/core.yaml#;
+
+title: TCAN104x CAN TRANSCEIVER PHY
+
+maintainers:
+  - Aswath Govindraju 
+
+properties:
+  $nodename:
+pattern: "^tcan104x-phy"
+
+  compatible:
+enum:
+  - ti,tcan1042
+  - ti,tcan1043
+
+  '#phy-cells':
+const: 0
+
+  standby-gpios:
+description:
+  gpio node to toggle standby signal on transceiver
+maxItems: 1
+
+  enable-gpios:
+description:
+  gpio node to toggle enable signal on transceiver
+maxItems: 1
+
+  max-bitrate:
+$ref: /schemas/types.yaml#/definitions/uint32
+description:
+  max bit rate supported in bps
+minimum: 1
+
+required:
+  - compatible
+  - '#phy-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+transceiver1: tcan104x-phy {
+  compatible = "ti,tcan1043";
+  #phy-cells = <0>;
+  max-bitrate = <500>;
+  standby-gpios = <_gpio1 16 GPIO_ACTIVE_LOW>;
+  enable-gpios = <_gpio1 67 GPIO_ACTIVE_LOW>;
+};
-- 
2.17.1



[PATCH 2/4] phy: phy-can-transceiver: Add support for generic CAN transceiver driver

2021-04-09 Thread Aswath Govindraju
The driver adds support for generic CAN transceivers. Currently
the modes supported by this driver are standby and normal modes for TI
TCAN1042 and TCAN1043 CAN transceivers.

The transceiver is modelled as a phy with pins controlled by gpios, to put
the transceiver in various device functional modes. It also gets the phy
attribute max_link_rate for the usage of m_can drivers.

Signed-off-by: Aswath Govindraju 
---
 drivers/phy/Kconfig   |   9 ++
 drivers/phy/Makefile  |   1 +
 drivers/phy/phy-can-transceiver.c | 140 ++
 3 files changed, 150 insertions(+)
 create mode 100644 drivers/phy/phy-can-transceiver.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 54c1f2f0985f..51902b629fc6 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -61,6 +61,15 @@ config USB_LGM_PHY
  interface to interact with USB GEN-II and USB 3.x PHY that is part
  of the Intel network SOC.
 
+config PHY_CAN_TRANSCEIVER
+   tristate "CAN transceiver PHY"
+   select GENERIC_PHY
+   help
+ This option enables support for CAN transceivers as a PHY. This
+ driver provides function for putting the transceivers in various
+ functional modes using gpios and sets the attribute max link
+ rate, for mcan drivers.
+
 source "drivers/phy/allwinner/Kconfig"
 source "drivers/phy/amlogic/Kconfig"
 source "drivers/phy/broadcom/Kconfig"
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index adac1b1a39d1..9c66101c9605 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_PHY_LPC18XX_USB_OTG)   += phy-lpc18xx-usb-otg.o
 obj-$(CONFIG_PHY_XGENE)+= phy-xgene.o
 obj-$(CONFIG_PHY_PISTACHIO_USB)+= phy-pistachio-usb.o
 obj-$(CONFIG_USB_LGM_PHY)  += phy-lgm-usb.o
+obj-$(CONFIG_PHY_CAN_TRANSCEIVER)  += phy-can-transceiver.o
 obj-y  += allwinner/   \
   amlogic/ \
   broadcom/\
diff --git a/drivers/phy/phy-can-transceiver.c 
b/drivers/phy/phy-can-transceiver.c
new file mode 100644
index ..14496f6e1666
--- /dev/null
+++ b/drivers/phy/phy-can-transceiver.c
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * phy-can-transceiver.c - phy driver for CAN transceivers
+ *
+ * Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com
+ *
+ */
+#include
+#include
+#include
+#include
+#include
+
+struct can_transceiver_data {
+   u32 flags;
+#define STB_PRESENTBIT(0)
+#define EN_PRESENT BIT(1)
+};
+
+struct can_transceiver_phy {
+   struct phy *generic_phy;
+   struct gpio_desc *standby_gpio;
+   struct gpio_desc *enable_gpio;
+};
+
+/* Power on function */
+static int can_transceiver_phy_power_on(struct phy *phy)
+{
+   struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
+
+   if (can_transceiver_phy->standby_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 0);
+   if (can_transceiver_phy->enable_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 1);
+   return 0;
+}
+
+/* Power off function */
+static int can_transceiver_phy_power_off(struct phy *phy)
+{
+   struct can_transceiver_phy *can_transceiver_phy = phy_get_drvdata(phy);
+
+   if (can_transceiver_phy->standby_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->standby_gpio, 1);
+   if (can_transceiver_phy->enable_gpio)
+   gpiod_set_value_cansleep(can_transceiver_phy->enable_gpio, 0);
+   return 0;
+}
+
+static const struct phy_ops can_transceiver_phy_ops = {
+   .power_on   = can_transceiver_phy_power_on,
+   .power_off  = can_transceiver_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
+static const struct can_transceiver_data tcan1042_drvdata = {
+   .flags = STB_PRESENT,
+};
+
+static const struct can_transceiver_data tcan1043_drvdata = {
+   .flags = STB_PRESENT | EN_PRESENT,
+};
+
+static const struct of_device_id can_transceiver_phy_ids[] = {
+   {
+   .compatible = "ti,tcan1042",
+   .data = _drvdata
+   },
+   {
+   .compatible = "ti,tcan1043",
+   .data = _drvdata
+   },
+   { }
+};
+MODULE_DEVICE_TABLE(of, can_transceiver_phy_ids);
+
+int can_transceiver_phy_probe(struct platform_device *pdev)
+{
+   struct phy_provider *phy_provider;
+   struct device *dev = >dev;
+   struct can_transceiver_phy *can_transceiver_phy;
+   const struct can_transceiver_data *drvdata;
+   const struct of_device_id *match;
+   struct phy *phy;
+   struct gpio_desc *standby_gpio;
+   struct gpio_desc *enable_gpio;
+   u32 max_bitrate = 0;
+
+   

[PATCH 0/4] CAN TRANSCEIVER: Add support for CAN transceivers

2021-04-09 Thread Aswath Govindraju
The following series of patches add support for CAN transceivers.

TCAN1042 has a standby signal that needs to be pulled high for
sending/receiving messages[1]. TCAN1043 has a enable signal along with
standby signal that needs to be pulled up for sending/receiving
messages[2], and other combinations of the two lines can be used to put the
transceiver in different states to reduce power consumption. On boards
like the AM654-idk and J721e-evm these signals are controlled using gpios.

Patch 1 models the transceiver as a phy device tree node with properties
for max bit rate supported, gpio properties for indicating gpio pin numbers
to which standby and enable signals are connected.

Patch 2 adds a generic driver to support CAN transceivers.

Patches 3 & 4 add support for implementing the transceiver as a phy of
m_can_platform driver.

Aswath Govindraju (2):
  dt-bindings: phy: Add binding for TI TCAN104x CAN transceivers
  phy: phy-can-transceiver: Add support for generic CAN transceiver
driver

Faiz Abbas (2):
  dt-bindings: net: can: Document transceiver implementation as phy
  can: m_can_platform: Add support for transceiver as phy

 .../bindings/net/can/bosch,m_can.yaml |   6 +
 .../bindings/phy/ti,tcan104x-can.yaml |  56 +++
 drivers/net/can/m_can/m_can_platform.c|  25 
 drivers/phy/Kconfig   |   9 ++
 drivers/phy/Makefile  |   1 +
 drivers/phy/phy-can-transceiver.c | 140 ++
 6 files changed, 237 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/ti,tcan104x-can.yaml
 create mode 100644 drivers/phy/phy-can-transceiver.c

-- 
2.17.1



[PATCH] arm64: dts: ti: k3-am65: Add support for UHS-I modes in MMCSD1 subsystem

2021-04-07 Thread Aswath Govindraju
UHS-I speed modes are supported in AM65 S.R. 2.0 SoC[1].

Add support by removing the no-1-8-v tag and including the voltage
regulator device tree nodes for power cycling.

[1] - https://www.ti.com/lit/ug/spruid7e/spruid7e.pdf, section 12.3.6.1.1

Signed-off-by: Aswath Govindraju 
---

test logs:
https://pastebin.ubuntu.com/p/vpYbY9QWh8/

 arch/arm64/boot/dts/ti/k3-am65-main.dtsi  |  1 -
 .../arm64/boot/dts/ti/k3-am654-base-board.dts | 33 +++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/ti/k3-am65-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-am65-main.dtsi
index cb340d1b401f..632f32fce4a1 100644
--- a/arch/arm64/boot/dts/ti/k3-am65-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am65-main.dtsi
@@ -301,7 +301,6 @@
ti,otap-del-sel = <0x2>;
ti,trm-icp = <0x8>;
dma-coherent;
-   no-1-8-v;
};
 
scm_conf: scm-conf@10 {
diff --git a/arch/arm64/boot/dts/ti/k3-am654-base-board.dts 
b/arch/arm64/boot/dts/ti/k3-am654-base-board.dts
index 9e87fb313a54..6f7292b6fe0a 100644
--- a/arch/arm64/boot/dts/ti/k3-am654-base-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-am654-base-board.dts
@@ -91,6 +91,38 @@
#clock-cells = <0>;
clock-frequency = <2400>;
};
+
+   evm_12v0: fixedregulator-evm12v0 {
+   /* main supply */
+   compatible = "regulator-fixed";
+   regulator-name = "evm_12v0";
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
+   vcc3v3_io: fixedregulator-vcc3v3io {
+   /* Output of TPS54334 */
+   compatible = "regulator-fixed";
+   regulator-name = "vcc3v3_io";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   regulator-boot-on;
+   vin-supply = <_12v0>;
+   };
+
+   vdd_mmc1_sd: fixedregulator-sd {
+   compatible = "regulator-fixed";
+   regulator-name = "vdd_mmc1_sd";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   enable-active-high;
+   vin-supply = <_io>;
+   gpio = < 4 GPIO_ACTIVE_HIGH>;
+   };
 };
 
 _pmx0 {
@@ -350,6 +382,7 @@
  * disable sdhci1
  */
  {
+   vmmc-supply = <_mmc1_sd>;
pinctrl-names = "default";
pinctrl-0 = <_mmc1_pins_default>;
ti,driver-strength-ohm = <50>;
-- 
2.17.1



[PATCH v9 2/3] arm64: dts: ti: k3-j7200-common-proc-board: Disable unused gpio modules

2021-03-26 Thread Aswath Govindraju
From: Faiz Abbas 

There are 6 gpio instances inside SoC with 2 groups as show below:
Group one: wkup_gpio0, wkup_gpio1
Group two: main_gpio0, main_gpio2, main_gpio4, main_gpio6

Only one instance from each group can be used at a time. So use main_gpio0
and wkup_gpio0 in current linux context and disable the rest of the nodes.

Signed-off-by: Faiz Abbas 
Signed-off-by: Sekhar Nori 
Signed-off-by: Aswath Govindraju 
Reviewed-by: Grygorii Strashko 
---
 .../boot/dts/ti/k3-j7200-common-proc-board.dts   | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
index 4a7182abccf5..b493f939b09a 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
@@ -122,6 +122,22 @@
status = "disabled";
 };
 
+_gpio2 {
+   status = "disabled";
+};
+
+_gpio4 {
+   status = "disabled";
+};
+
+_gpio6 {
+   status = "disabled";
+};
+
+_gpio1 {
+   status = "disabled";
+};
+
 _cpsw {
pinctrl-names = "default";
pinctrl-0 = <_cpsw_pins_default _mdio_pins_default>;
-- 
2.17.1



[PATCH v9 1/3] arm64: dts: ti: k3-j7200: Add gpio nodes

2021-03-26 Thread Aswath Govindraju
From: Faiz Abbas 

There are 4 instances of gpio modules in main domain:
gpio0, gpio2, gpio4 and gpio6

Groups are created to provide protection between different processor
virtual worlds. Each of these modules I/O pins are muxed within the
group. Exactly one module can be selected to control the corresponding
pin by selecting it in the pad mux configuration registers.

This group in main domain pins out 69 lines (5 banks). Add DT modes for
each module instance in the main domain.

Similar to the gpio groups in main domain, there is one gpio group in
wakeup domain with 2 module instances in it.

The gpio group pins out 72 pins (6 banks) of the first 85 gpio lines. Add
DT nodes for each module instance in the wakeup domain.

Signed-off-by: Faiz Abbas 
Signed-off-by: Sekhar Nori 
Signed-off-by: Aswath Govindraju 
Reviewed-by: Grygorii Strashko 
---
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 72 +++
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi  | 34 +
 2 files changed, 106 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
index 17477ab0fd8e..e60650a62b14 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
@@ -672,6 +672,78 @@
};
};
 
+   main_gpio0: gpio@60 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0060 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <145>, <146>, <147>, <148>,
+<149>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 105 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 105 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio2: gpio@61 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0061 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <154>, <155>, <156>, <157>,
+<158>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 107 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 107 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio4: gpio@62 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0062 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <163>, <164>, <165>, <166>,
+<167>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 109 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 109 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio6: gpio@63 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0063 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <172>, <173>, <174>, <175>,
+<176>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 111 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 111 0>;
+   clock-names = "gpio";
+   };
+
main_r5fss0: r5fss@5c0 {
compatible = "ti,j7200-r5fss";
ti,cluster-mode = <1>;
diff --git a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
index 5408ec815d58..4e4ea7655fe2 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
+++ b/

[PATCH v9 3/3] arm64: dts: ti: k3-j7200: Add support for higher speed modes and update delay select values for MMCSD subsystems

2021-03-26 Thread Aswath Govindraju
The following speed modes are now supported in J7200 SoC,
- HS200 and HS400 modes at 1.8 V card voltage, in MMCSD0 subsystem [1].
- UHS-I speed modes in MMCSD1 subsystem [1].

Add support for UHS-I modes by adding voltage regulator device tree nodes
and corresponding pinmux details, to power cycle and voltage switch cards.
Set respective tags in sdhci0 and remove no-1-8-v tag from sdhci1
device tree nodes.

Also update the delay values for various speed modes supported, based on
the revised january 2021 J7200 datasheet[2].

[1] - section 12.3.6.1.1 MMCSD Features, in
  https://www.ti.com/lit/ug/spruiu1a/spruiu1a.pdf,
  (SPRUIU1A – JULY 2020 – REVISED JANUARY 2021)

[2] - https://www.ti.com/lit/ds/symlink/dra821u.pdf,
  (SPRSP57B – APRIL 2020 – REVISED JANUARY 2021)

Signed-off-by: Aswath Govindraju 
Reviewed-by: Kishon Vijay Abraham I 
---
 .../dts/ti/k3-j7200-common-proc-board.dts | 78 +++
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 14 +++-
 2 files changed, 90 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
index b493f939b09a..bedd01b7a32c 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
@@ -16,6 +16,65 @@
stdout-path = "serial2:115200n8";
bootargs = "console=ttyS2,115200n8 
earlycon=ns16550a,mmio32,0x0280";
};
+
+   evm_12v0: fixedregulator-evm12v0 {
+   /* main supply */
+   compatible = "regulator-fixed";
+   regulator-name = "evm_12v0";
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
+   vsys_3v3: fixedregulator-vsys3v3 {
+   /* Output of LM5140 */
+   compatible = "regulator-fixed";
+   regulator-name = "vsys_3v3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   vin-supply = <_12v0>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
+   vsys_5v0: fixedregulator-vsys5v0 {
+   /* Output of LM5140 */
+   compatible = "regulator-fixed";
+   regulator-name = "vsys_5v0";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_12v0>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
+   vdd_mmc1: fixedregulator-sd {
+   /* Output of TPS22918 */
+   compatible = "regulator-fixed";
+   regulator-name = "vdd_mmc1";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   enable-active-high;
+   vin-supply = <_3v3>;
+   gpio = < 2 GPIO_ACTIVE_HIGH>;
+   };
+
+   vdd_sd_dv: gpio-regulator-TLV71033 {
+   /* Output of TLV71033 */
+   compatible = "regulator-gpio";
+   regulator-name = "tlv71033";
+   pinctrl-names = "default";
+   pinctrl-0 = <_sd_dv_pins_default>;
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   vin-supply = <_5v0>;
+   gpios = <_gpio0 55 GPIO_ACTIVE_HIGH>;
+   states = <180 0x0>,
+<330 0x1>;
+   };
 };
 
 _pmx0 {
@@ -45,6 +104,13 @@
 };
 
 _pmx0 {
+   main_i2c0_pins_default: main-i2c0-pins-default {
+   pinctrl-single,pins = <
+   J721E_IOPAD(0xd4, PIN_INPUT_PULLUP, 0) /* (V3) I2C0_SCL 
*/
+   J721E_IOPAD(0xd8, PIN_INPUT_PULLUP, 0) /* (W2) I2C0_SDA 
*/
+   >;
+   };
+
main_i2c1_pins_default: main-i2c1-pins-default {
pinctrl-single,pins = <
J721E_IOPAD(0xdc, PIN_INPUT_PULLUP, 3) /* (U3) 
ECAP0_IN_APWM_OUT.I2C1_SCL */
@@ -70,6 +136,12 @@
J721E_IOPAD(0x120, PIN_OUTPUT, 0) /* (T4) USB0_DRVVBUS 
*/
>;
};
+
+   vdd_sd_dv_pins_default: vdd-sd-dv-pins-default {
+   pinctrl-single,pins = <
+   J721E_IOPAD(0xd0, PIN_OUTPUT, 7) /* (T5) 
SPI0_D1.GPIO0_55 */
+   >;
+   };
 };
 
 _uart0 {
@@ -157,6 +229,10 @@
 };
 
 _i2c0 {
+   pinctrl-names = "default";
+   pinctrl-0 = &

[PATCH v9 0/3] J7200: Add support for GPIO and higher speed modes in MMCSD subsystems

2021-03-26 Thread Aswath Govindraju
The following series of patches
- Add support for GPIO subsystem in main and wakeup domains.
- Add voltage regulator device tree nodes and their corresponding pinmux
  to support power cycle and voltage switch required for UHS-I modes
- sets respective tags in sdhci0 node to support higher speeds
- remove no-1-8-v tag from sdhci1 node to support UHS-I modes
- Update delay values for various speed modes supported.


test logs
- eMMC HS400 speed mode
  https://pastebin.ubuntu.com/p/pRzV2ZvSJZ/

- SD SDR104 speed mode
  https://pastebin.ubuntu.com/p/n64PNdDy2v/

- GPIO logs
  https://pastebin.ubuntu.com/p/HDBBMwMcdj/

Changes since v8:
- Fixed minor changes sugested by kishon in patch 3
- Picked up kishon's reviewed-by for patch 3

Changes since v7:
- Added the voltage regulator nodes to indicate the complete
  power flow for MMCSD1 subsystem
- Corrected minor errors in DT nodes
- Reran the tests.
- Rebased the series

Changes since v6:
- Corrected the node name from vdd_sd_dv_pins_default to
  vdd-sd-dv-pins-default

Changes since v5:
- Corrected the link in patch 3 as it broken.
- Added the version number for the references used in patch 3.
- picked up reviewed-by from grygorii for patches 1 and 2.

Changes since v4:
- Added main_i2c0 pinmux required for doing power cycles to MMCSD1
  subsystem
- Updated delay values for various speed modes supported
- Corrected the ti,ngpio property to indicate highest gpio lines that
  can be accessed.
- Reran the performace tests

Changes since v3:
- Removed patch (1 in v3).
- Rebased and included patches that add support for GPIO from series [1].
- Re-ran the performace tests for SD and eMMC.

Changes since v2:
- Added main_gpio0 DT node
- Added voltage regulator device tree nodes required to support UHS-I modes

Changes since v1:
- squashed the two patches into one
- added performance logs for the above mentioned speed modes

Aswath Govindraju (1):
  arm64: dts: ti: k3-j7200: Add support for higher speed modes and
update delay select values for MMCSD subsystems

Faiz Abbas (2):
  arm64: dts: ti: k3-j7200: Add gpio nodes
  arm64: dts: ti: k3-j7200-common-proc-board: Disable unused gpio
modules

 .../dts/ti/k3-j7200-common-proc-board.dts | 94 +++
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 86 -
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi  | 34 +++
 3 files changed, 212 insertions(+), 2 deletions(-)

-- 
2.17.1



Re: [PATCH v8 3/3] arm64: dts: ti: k3-j7200: Add support for higher speed modes and update delay select values for MMCSD subsystems

2021-03-26 Thread Aswath Govindraju
Hi Kishon,

On 25/03/21 9:44 pm, Kishon Vijay Abraham I wrote:
> Hi Aswath,
> 
> On 24/03/21 12:07 pm, Aswath Govindraju wrote:
>> The following speed modes are now supported in J7200 SoC,
>> - HS200 and HS400 modes at 1.8 V card voltage, in MMCSD0 subsystem [1].
>> - UHS-I speed modes in MMCSD1 subsystem [1].
>>
>> Add support for UHS-I modes by adding voltage regulator device tree nodes
>> and corresponding pinmux details, to power cycle and voltage switch cards.
>> Set respective tags in sdhci0 and remove no-1-8-v tag from sdhci1
>> device tree nodes.
>>
>> Also update the delay values for various speed modes supported, based on
>> the revised january 2021 J7200 datasheet[2].
>>
>> [1] - section 12.3.6.1.1 MMCSD Features, in
>>   https://www.ti.com/lit/ug/spruiu1a/spruiu1a.pdf,
>>   (SPRUIU1A – JULY 2020 – REVISED JANUARY 2021)
>>
>> [2] - https://www.ti.com/lit/ds/symlink/dra821u.pdf,
>>   (SPRSP57B – APRIL 2020 – REVISED JANUARY 2021)
> minor comments below.. once you fix them, please add
> 
> Reviewed-by: Kishon Vijay Abraham I 
>>

Thank you for your review :).

>> Signed-off-by: Aswath Govindraju 
>> ---
>>  .../dts/ti/k3-j7200-common-proc-board.dts | 78 +++
>>  arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 14 +++-
>>  2 files changed, 90 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
>> b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>> index b493f939b09a..a069787e1783 100644
>> --- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>> +++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>> @@ -16,6 +16,65 @@
>>  stdout-path = "serial2:115200n8";
>>  bootargs = "console=ttyS2,115200n8 
>> earlycon=ns16550a,mmio32,0x0280";
>>  };
>> +
>> +evm_12v0: fixedregulator-evm12v0 {
>> +/* main supply */
>> +compatible = "regulator-fixed";
>> +regulator-name = "evm_12v0";
>> +regulator-min-microvolt = <1200>;
>> +regulator-max-microvolt = <1200>;
>> +regulator-always-on;
>> +regulator-boot-on;
>> +};
>> +
>> +vsys_3v3: fixedregulator-vsys3v3 {
>> +/* Output of LMS140 */
> 
> %s/LMS140/LM5140

Will make this change in respin.

>> +compatible = "regulator-fixed";
>> +regulator-name = "vsys_3v3";
>> +regulator-min-microvolt = <330>;
>> +regulator-max-microvolt = <330>;
>> +vin-supply = <_12v0>;
>> +regulator-always-on;
>> +regulator-boot-on;
>> +};
>> +
>> +vsys_5v0: fixedregulator-vsys5v0 {
>> +/* Output of LM5140 */
>> +compatible = "regulator-fixed";
>> +regulator-name = "vsys_5v0";
>> +regulator-min-microvolt = <500>;
>> +regulator-max-microvolt = <500>;
>> +vin-supply = <_12v0>;
>> +regulator-always-on;
>> +regulator-boot-on;
>> +};
>> +
>> +vdd_mmc1: fixedregulator-sd {
>> +/* Output of TPS22918  */
>> +compatible = "regulator-fixed";
>> +regulator-name = "vdd_mmc1";
>> +regulator-min-microvolt = <330>;
>> +regulator-max-microvolt = <330>;
>> +regulator-boot-on;
>> +enable-active-high;
>> +vin-supply = <_3v3>;
>> +gpio = < 2 GPIO_ACTIVE_HIGH>;
>> +};
>> +
>> +vdd_sd_dv: gpio-regulator-vdd-sd-dv {
>> +/* Output of TLV71033 */
> 
> Would have preferred to keep this similar to j721e.
> gpio-regulator-TLV71033 is used in j721e

Will make this change in respin

>> +compatible = "regulator-gpio";
>> +regulator-name = "vdd_sd_dv";
> 
> same comment here..

Will make this change in respin

>> +pinctrl-names = "default";
>> +pinctrl-0 = <_sd_dv_pins_default>;
>> +regulator-min-microvolt = <180>;
>> +regulator-max-microvolt = <330>;
>> +regulator-boot-on;
>> +vin-supply = <_5v0>;
>> +  

[PATCH v8 3/3] arm64: dts: ti: k3-j7200: Add support for higher speed modes and update delay select values for MMCSD subsystems

2021-03-24 Thread Aswath Govindraju
The following speed modes are now supported in J7200 SoC,
- HS200 and HS400 modes at 1.8 V card voltage, in MMCSD0 subsystem [1].
- UHS-I speed modes in MMCSD1 subsystem [1].

Add support for UHS-I modes by adding voltage regulator device tree nodes
and corresponding pinmux details, to power cycle and voltage switch cards.
Set respective tags in sdhci0 and remove no-1-8-v tag from sdhci1
device tree nodes.

Also update the delay values for various speed modes supported, based on
the revised january 2021 J7200 datasheet[2].

[1] - section 12.3.6.1.1 MMCSD Features, in
  https://www.ti.com/lit/ug/spruiu1a/spruiu1a.pdf,
  (SPRUIU1A – JULY 2020 – REVISED JANUARY 2021)

[2] - https://www.ti.com/lit/ds/symlink/dra821u.pdf,
  (SPRSP57B – APRIL 2020 – REVISED JANUARY 2021)

Signed-off-by: Aswath Govindraju 
---
 .../dts/ti/k3-j7200-common-proc-board.dts | 78 +++
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 14 +++-
 2 files changed, 90 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
index b493f939b09a..a069787e1783 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
@@ -16,6 +16,65 @@
stdout-path = "serial2:115200n8";
bootargs = "console=ttyS2,115200n8 
earlycon=ns16550a,mmio32,0x0280";
};
+
+   evm_12v0: fixedregulator-evm12v0 {
+   /* main supply */
+   compatible = "regulator-fixed";
+   regulator-name = "evm_12v0";
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
+   vsys_3v3: fixedregulator-vsys3v3 {
+   /* Output of LMS140 */
+   compatible = "regulator-fixed";
+   regulator-name = "vsys_3v3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   vin-supply = <_12v0>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
+   vsys_5v0: fixedregulator-vsys5v0 {
+   /* Output of LM5140 */
+   compatible = "regulator-fixed";
+   regulator-name = "vsys_5v0";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_12v0>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+
+   vdd_mmc1: fixedregulator-sd {
+   /* Output of TPS22918  */
+   compatible = "regulator-fixed";
+   regulator-name = "vdd_mmc1";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   enable-active-high;
+   vin-supply = <_3v3>;
+   gpio = < 2 GPIO_ACTIVE_HIGH>;
+   };
+
+   vdd_sd_dv: gpio-regulator-vdd-sd-dv {
+   /* Output of TLV71033 */
+   compatible = "regulator-gpio";
+   regulator-name = "vdd_sd_dv";
+   pinctrl-names = "default";
+   pinctrl-0 = <_sd_dv_pins_default>;
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   vin-supply = <_5v0>;
+   gpios = <_gpio0 55 GPIO_ACTIVE_HIGH>;
+   states = <180 0x0>,
+<330 0x1>;
+   };
 };
 
 _pmx0 {
@@ -45,6 +104,13 @@
 };
 
 _pmx0 {
+   main_i2c0_pins_default: main-i2c0-pins-default {
+   pinctrl-single,pins = <
+   J721E_IOPAD(0xd4, PIN_INPUT_PULLUP, 0) /* (V3) I2C0_SCL 
*/
+   J721E_IOPAD(0xd8, PIN_INPUT_PULLUP, 0) /* (W2) I2C0_SDA 
*/
+   >;
+   };
+
main_i2c1_pins_default: main-i2c1-pins-default {
pinctrl-single,pins = <
J721E_IOPAD(0xdc, PIN_INPUT_PULLUP, 3) /* (U3) 
ECAP0_IN_APWM_OUT.I2C1_SCL */
@@ -70,6 +136,12 @@
J721E_IOPAD(0x120, PIN_OUTPUT, 0) /* (T4) USB0_DRVVBUS 
*/
>;
};
+
+   vdd_sd_dv_pins_default: vdd-sd-dv-pins-default {
+   pinctrl-single,pins = <
+   J721E_IOPAD(0xd0, PIN_INPUT, 7) /* (T5) 
SPI0_D1.GPIO0_55 */
+   >;
+   };
 };
 
 _uart0 {
@@ -157,6 +229,10 @@
 };
 
 _i2c0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <_i2c0_pins_default>;
+   clock-freque

[PATCH v8 2/3] arm64: dts: ti: k3-j7200-common-proc-board: Disable unused gpio modules

2021-03-24 Thread Aswath Govindraju
From: Faiz Abbas 

There are 6 gpio instances inside SoC with 2 groups as show below:
Group one: wkup_gpio0, wkup_gpio1
Group two: main_gpio0, main_gpio2, main_gpio4, main_gpio6

Only one instance from each group can be used at a time. So use main_gpio0
and wkup_gpio0 in current linux context and disable the rest of the nodes.

Signed-off-by: Faiz Abbas 
Signed-off-by: Sekhar Nori 
Signed-off-by: Aswath Govindraju 
Reviewed-by: Grygorii Strashko 
---
 .../boot/dts/ti/k3-j7200-common-proc-board.dts   | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
index 4a7182abccf5..b493f939b09a 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
@@ -122,6 +122,22 @@
status = "disabled";
 };
 
+_gpio2 {
+   status = "disabled";
+};
+
+_gpio4 {
+   status = "disabled";
+};
+
+_gpio6 {
+   status = "disabled";
+};
+
+_gpio1 {
+   status = "disabled";
+};
+
 _cpsw {
pinctrl-names = "default";
pinctrl-0 = <_cpsw_pins_default _mdio_pins_default>;
-- 
2.17.1



[PATCH v8 1/3] arm64: dts: ti: k3-j7200: Add gpio nodes

2021-03-24 Thread Aswath Govindraju
From: Faiz Abbas 

There are 4 instances of gpio modules in main domain:
gpio0, gpio2, gpio4 and gpio6

Groups are created to provide protection between different processor
virtual worlds. Each of these modules I/O pins are muxed within the
group. Exactly one module can be selected to control the corresponding
pin by selecting it in the pad mux configuration registers.

This group in main domain pins out 69 lines (5 banks). Add DT modes for
each module instance in the main domain.

Similar to the gpio groups in main domain, there is one gpio group in
wakeup domain with 2 module instances in it.

The gpio group pins out 72 pins (6 banks) of the first 85 gpio lines. Add
DT nodes for each module instance in the wakeup domain.

Signed-off-by: Faiz Abbas 
Signed-off-by: Sekhar Nori 
Signed-off-by: Aswath Govindraju 
Reviewed-by: Grygorii Strashko 
---
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 72 +++
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi  | 34 +
 2 files changed, 106 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
index 17477ab0fd8e..e60650a62b14 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
@@ -672,6 +672,78 @@
};
};
 
+   main_gpio0: gpio@60 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0060 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <145>, <146>, <147>, <148>,
+<149>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 105 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 105 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio2: gpio@61 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0061 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <154>, <155>, <156>, <157>,
+<158>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 107 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 107 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio4: gpio@62 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0062 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <163>, <164>, <165>, <166>,
+<167>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 109 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 109 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio6: gpio@63 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0063 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <172>, <173>, <174>, <175>,
+<176>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 111 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 111 0>;
+   clock-names = "gpio";
+   };
+
main_r5fss0: r5fss@5c0 {
compatible = "ti,j7200-r5fss";
ti,cluster-mode = <1>;
diff --git a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
index 5408ec815d58..4e4ea7655fe2 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
+++ b/

[PATCH v8 0/3] J7200: Add support for GPIO and higher speed modes in MMCSD subsystems

2021-03-24 Thread Aswath Govindraju
The following series of patches
- Add support for GPIO subsystem in main and wakeup domains.
- Add voltage regulator device tree nodes and their corresponding pinmux
  to support power cycle and voltage switch required for UHS-I modes
- sets respective tags in sdhci0 node to support higher speeds
- remove no-1-8-v tag from sdhci1 node to support UHS-I modes
- Update delay values for various speed modes supported.


test logs
- eMMC HS400 speed mode
  https://pastebin.ubuntu.com/p/pRzV2ZvSJZ/

- SD SDR104 speed mode
  https://pastebin.ubuntu.com/p/n64PNdDy2v/  
  
- GPIO logs
  https://pastebin.ubuntu.com/p/HDBBMwMcdj/

Changes since v7:
- Added the voltage regulator nodes to indicate the complete
  power flow for MMCSD1 subsystem
- Corrected minor errors in DT nodes
- Reran the tests.
- Rebased the series

Changes since v6:
- Corrected the node name from vdd_sd_dv_pins_default to
  vdd-sd-dv-pins-default

Changes since v5:
- Corrected the link in patch 3 as it broken.
- Added the version number for the references used in patch 3.
- picked up reviewed-by from grygorii for patches 1 and 2.

Changes since v4:
- Added main_i2c0 pinmux required for doing power cycles to MMCSD1
  subsystem
- Updated delay values for various speed modes supported
- Corrected the ti,ngpio property to indicate highest gpio lines that
  can be accessed.
- Reran the performace tests

Changes since v3:
- Removed patch (1 in v3).
- Rebased and included patches that add support for GPIO from series [1].
- Re-ran the performace tests for SD and eMMC.

Changes since v2:
- Added main_gpio0 DT node
- Added voltage regulator device tree nodes required to support UHS-I modes

Changes since v1:
- squashed the two patches into one
- added performance logs for the above mentioned speed modes


Aswath Govindraju (1):
  arm64: dts: ti: k3-j7200: Add support for higher speed modes and
update delay select values for MMCSD subsystems

Faiz Abbas (2):
  arm64: dts: ti: k3-j7200: Add gpio nodes
  arm64: dts: ti: k3-j7200-common-proc-board: Disable unused gpio
modules

 .../dts/ti/k3-j7200-common-proc-board.dts | 94 +++
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 86 -
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi  | 34 +++
 3 files changed, 212 insertions(+), 2 deletions(-)

-- 
2.17.1



Re: [PATCH v7 3/3] arm64: dts: ti: k3-j7200: Add support for higher speed modes and update delay select values for MMCSD subsystems

2021-03-23 Thread Aswath Govindraju
Hi Kishon,

On 23/03/21 11:59 am, Kishon Vijay Abraham I wrote:
> Hi Aswath,
> 
> On 23/03/21 10:54 am, Aswath Govindraju wrote:
>> Hi Nishanth,
>>
>> On 22/03/21 9:05 pm, Nishanth Menon wrote:
>>> On 18:42-20210322, Aswath Govindraju wrote:
>>>> The following speed modes are now supported in J7200 SoC,
>>>> - HS200 and HS400 modes at 1.8 V card voltage, in MMCSD0 subsystem [1].
>>>> - UHS-I speed modes in MMCSD1 subsystem [1].
>>>>
>>>> Add support for UHS-I modes by adding voltage regulator device tree nodes
>>>> and corresponding pinmux details, to power cycle and voltage switch cards.
>>>> Set respective tags in sdhci0 and remove no-1-8-v tag from sdhci1
>>>> device tree nodes.
>>>>
>>>> Also update the delay values for various speed modes supported, based on
>>>> the revised january 2021 J7200 datasheet[2].
>>>>
>>>> [1] - section 12.3.6.1.1 MMCSD Features, in
>>>>   https://www.ti.com/lit/ug/spruiu1a/spruiu1a.pdf,
>>>>   (SPRUIU1A – JULY 2020 – REVISED JANUARY 2021)
>>>>
>>>> [2] - https://www.ti.com/lit/ds/symlink/dra821u.pdf,
>>>>   (SPRSP57B – APRIL 2020 – REVISED JANUARY 2021)
>>>>
>>>> Signed-off-by: Aswath Govindraju 
>>>> ---
>>>>  .../dts/ti/k3-j7200-common-proc-board.dts | 42 +++
>>>>  arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 14 ++-
>>>>  2 files changed, 54 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
>>>> b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>>>> index b493f939b09a..de8c06bdc825 100644
>>>> --- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>>>> +++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>>>> @@ -16,6 +16,29 @@
>>>>stdout-path = "serial2:115200n8";
>>>>bootargs = "console=ttyS2,115200n8 
>>>> earlycon=ns16550a,mmio32,0x0280";
>>>>};
>>>> +
>>>> +  vdd_mmc1: fixedregulator-sd {
>>>> +  compatible = "regulator-fixed";
>>>> +  regulator-name = "vdd_mmc1";
>>>> +  regulator-min-microvolt = <330>;
>>>> +  regulator-max-microvolt = <330>;
>>>> +  regulator-boot-on;
>>>> +  enable-active-high;
>>>> +  gpios = < 2 GPIO_ACTIVE_HIGH>;
>>>
>>> is that gpio ?
>>
>> Yes, that is correct. I'll correct it in the respin
>>
>>> I'd encourage to use vin-supply as well.
>>
>> Will add this in respin.
>>
>>>
>>>> +  };
>>>> +
>>>> +  vdd_sd_dv: gpio-regulator-vdd-sd-dv {
>>> What does this drive? TLV71033 ?
>>
>> Yes, this node models the TLV71033 voltage regulator that switches the
>> MMC IO signal voltage level between 3.3V and 1.8V.
> 
> Nope. Unlike J721e SOM which uses TLV71033 for switching voltage, J7200
> SOM directly uses GPIO input to PMIC to control the output voltage. So
> this should model the gpio input to PMIC.
> 

This was the case with older SoMs and on newer ones load switches are
being used[1].

[1] - https://www.ti.com/lit/zip/sprr424, PROC105E6(001)_SCH.pdf, page 24

Thanks,
Aswath


Re: [PATCH v7 3/3] arm64: dts: ti: k3-j7200: Add support for higher speed modes and update delay select values for MMCSD subsystems

2021-03-22 Thread Aswath Govindraju
Hi Nishanth,

On 22/03/21 9:05 pm, Nishanth Menon wrote:
> On 18:42-20210322, Aswath Govindraju wrote:
>> The following speed modes are now supported in J7200 SoC,
>> - HS200 and HS400 modes at 1.8 V card voltage, in MMCSD0 subsystem [1].
>> - UHS-I speed modes in MMCSD1 subsystem [1].
>>
>> Add support for UHS-I modes by adding voltage regulator device tree nodes
>> and corresponding pinmux details, to power cycle and voltage switch cards.
>> Set respective tags in sdhci0 and remove no-1-8-v tag from sdhci1
>> device tree nodes.
>>
>> Also update the delay values for various speed modes supported, based on
>> the revised january 2021 J7200 datasheet[2].
>>
>> [1] - section 12.3.6.1.1 MMCSD Features, in
>>   https://www.ti.com/lit/ug/spruiu1a/spruiu1a.pdf,
>>   (SPRUIU1A – JULY 2020 – REVISED JANUARY 2021)
>>
>> [2] - https://www.ti.com/lit/ds/symlink/dra821u.pdf,
>>   (SPRSP57B – APRIL 2020 – REVISED JANUARY 2021)
>>
>> Signed-off-by: Aswath Govindraju 
>> ---
>>  .../dts/ti/k3-j7200-common-proc-board.dts | 42 +++
>>  arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 14 ++-
>>  2 files changed, 54 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
>> b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>> index b493f939b09a..de8c06bdc825 100644
>> --- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>> +++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>> @@ -16,6 +16,29 @@
>>  stdout-path = "serial2:115200n8";
>>  bootargs = "console=ttyS2,115200n8 
>> earlycon=ns16550a,mmio32,0x0280";
>>  };
>> +
>> +vdd_mmc1: fixedregulator-sd {
>> +compatible = "regulator-fixed";
>> +regulator-name = "vdd_mmc1";
>> +regulator-min-microvolt = <330>;
>> +regulator-max-microvolt = <330>;
>> +regulator-boot-on;
>> +enable-active-high;
>> +gpios = < 2 GPIO_ACTIVE_HIGH>;
> 
> is that gpio ?

Yes, that is correct. I'll correct it in the respin

> I'd encourage to use vin-supply as well.

Will add this in respin.

> 
>> +};
>> +
>> +vdd_sd_dv: gpio-regulator-vdd-sd-dv {
>   What does this drive? TLV71033 ?

Yes, this node models the TLV71033 voltage regulator that switches the
MMC IO signal voltage level between 3.3V and 1.8V.


>> +compatible = "regulator-gpio";
>> +regulator-name = "vdd_sd_dv";
>> +pinctrl-names = "default";
>> +pinctrl-0 = <_sd_dv_pins_default>;
>> +regulator-min-microvolt = <180>;
>> +regulator-max-microvolt = <330>;
>> +regulator-boot-on;
> 
> normally, I'd encourage to use vin-supply as well.

Will add this in the respin

> 
>> +gpios = <_gpio0 55 GPIO_ACTIVE_HIGH>;
>> +states = <180 0x0
>> +  330 0x1>;
> states = <180 0x0>,
> <330 0x1>;
> 

Will make this change in the respin.

> Can you look at j721e as reference?
> 

Will make changes accordingly.

>> +};
>>  };
>>  
> 
> Kishon,
>   can you look closer at this series?
> 

I'll wait for kishon's feedback and then post respin of this series.


Thank you for the review.

Regards,
Aswath


Re: [PATCH v6 3/3] arm64: dts: ti: k3-j7200: Add support for higher speed modes and update delay select values for MMCSD subsystems

2021-03-22 Thread Aswath Govindraju
Hi Nishanth,

On 22/03/21 5:53 pm, Nishanth Menon wrote:
> On 09:14-20210319, Aswath Govindraju wrote:
>> The following speed modes are now supported in J7200 SoC,
>> - HS200 and HS400 modes at 1.8 V card voltage, in MMCSD0 subsystem [1].
>> - UHS-I speed modes in MMCSD1 subsystem [1].
>>
>> Add support for UHS-I modes by adding voltage regulator device tree nodes
>> and corresponding pinmux details, to power cycle and voltage switch cards.
>> Set respective tags in sdhci0 and remove no-1-8-v tag from sdhci1
>> device tree nodes.
>>
>> Also update the delay values for various speed modes supported, based on
>> the revised january 2021 J7200 datasheet[2].
>>
>> [1] - section 12.3.6.1.1 MMCSD Features, in
>>   https://www.ti.com/lit/ug/spruiu1a/spruiu1a.pdf,
>>   (SPRUIU1A – JULY 2020 – REVISED JANUARY 2021)
>>
>> [2] - https://www.ti.com/lit/ds/symlink/dra821u.pdf,
>>   (SPRSP57B – APRIL 2020 – REVISED JANUARY 2021)
>>
>> Signed-off-by: Aswath Govindraju 
>> ---
> [...]
> 
>> +
>> +vdd_sd_dv_pins_default: vdd_sd_dv_pins_default {
> 
>   Nope. Use:
>   vdd_sd_dv_pins_default: vdd-sd-dv-pins-default
> 

Corrected this in the respin(v7).

Thanks,
Aswath


[PATCH v7 2/3] arm64: dts: ti: k3-j7200-common-proc-board: Disable unused gpio modules

2021-03-22 Thread Aswath Govindraju
From: Faiz Abbas 

There are 6 gpio instances inside SoC with 2 groups as show below:
Group one: wkup_gpio0, wkup_gpio1
Group two: main_gpio0, main_gpio2, main_gpio4, main_gpio6

Only one instance from each group can be used at a time. So use main_gpio0
and wkup_gpio0 in current linux context and disable the rest of the nodes.

Signed-off-by: Faiz Abbas 
Signed-off-by: Sekhar Nori 
Signed-off-by: Aswath Govindraju 
Reviewed-by: Grygorii Strashko 
---
 .../boot/dts/ti/k3-j7200-common-proc-board.dts   | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
index 4a7182abccf5..b493f939b09a 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
@@ -122,6 +122,22 @@
status = "disabled";
 };
 
+_gpio2 {
+   status = "disabled";
+};
+
+_gpio4 {
+   status = "disabled";
+};
+
+_gpio6 {
+   status = "disabled";
+};
+
+_gpio1 {
+   status = "disabled";
+};
+
 _cpsw {
pinctrl-names = "default";
pinctrl-0 = <_cpsw_pins_default _mdio_pins_default>;
-- 
2.17.1



[PATCH v7 1/3] arm64: dts: ti: k3-j7200: Add gpio nodes

2021-03-22 Thread Aswath Govindraju
From: Faiz Abbas 

There are 4 instances of gpio modules in main domain:
gpio0, gpio2, gpio4 and gpio6

Groups are created to provide protection between different processor
virtual worlds. Each of these modules I/O pins are muxed within the
group. Exactly one module can be selected to control the corresponding
pin by selecting it in the pad mux configuration registers.

This group in main domain pins out 69 lines (5 banks). Add DT modes for
each module instance in the main domain.

Similar to the gpio groups in main domain, there is one gpio group in
wakeup domain with 2 module instances in it.

The gpio group pins out 72 pins (6 banks) of the first 85 gpio lines. Add
DT nodes for each module instance in the wakeup domain.

Signed-off-by: Faiz Abbas 
Signed-off-by: Sekhar Nori 
Signed-off-by: Aswath Govindraju 
Reviewed-by: Grygorii Strashko 
---
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 72 +++
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi  | 34 +
 2 files changed, 106 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
index 17477ab0fd8e..e60650a62b14 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
@@ -672,6 +672,78 @@
};
};
 
+   main_gpio0: gpio@60 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0060 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <145>, <146>, <147>, <148>,
+<149>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 105 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 105 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio2: gpio@61 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0061 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <154>, <155>, <156>, <157>,
+<158>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 107 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 107 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio4: gpio@62 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0062 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <163>, <164>, <165>, <166>,
+<167>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 109 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 109 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio6: gpio@63 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0063 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <172>, <173>, <174>, <175>,
+<176>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 111 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 111 0>;
+   clock-names = "gpio";
+   };
+
main_r5fss0: r5fss@5c0 {
compatible = "ti,j7200-r5fss";
ti,cluster-mode = <1>;
diff --git a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
index 359e3e8a8cd0..1dd5b30edc6c 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
+++ b/

[PATCH v7 0/3] J7200: Add support for GPIO and higher speed modes in MMCSD subsystems

2021-03-22 Thread Aswath Govindraju
The following series of patches
- Add support for GPIO subsystem in main and wakeup domains.
- Add voltage regulator device tree nodes and their corresponding pinmux
  to support power cycle and voltage switch required for UHS-I modes
- sets respective tags in sdhci0 node to support higher speeds
- remove no-1-8-v tag from sdhci1 node to support UHS-I modes
- Update delay values for various speed modes supported.


test logs
- eMMC HS400 speed mode
https://pastebin.ubuntu.com/p/xqZt34mRWf/

- SD SDR104 speed mode
https://pastebin.ubuntu.com/p/qM2H85SQvX/

- GPIO logs
https://pastebin.ubuntu.com/p/7WXdRxxdWz/

Changes since v6:
- Corrected the node name from vdd_sd_dv_pins_default to
  vdd-sd-dv-pins-default

Changes since v5:
- Corrected the link in patch 3 as it broken.
- Added the version number for the references used in patch 3.
- picked up reviewed-by from grygorii for patches 1 and 2.

Changes since v4:
- Added main_i2c0 pinmux required for doing power cycles to MMCSD1
  subsystem
- Updated delay values for various speed modes supported
- Corrected the ti,ngpio property to indicate highest gpio lines that
  can be accessed.
- Reran the performace tests

Changes since v3:
- Removed patch (1 in v3).
- Rebased and included patches that add support for GPIO from series [1].
- Re-ran the performace tests for SD and eMMC.

Changes since v2:
- Added main_gpio0 DT node
- Added voltage regulator device tree nodes required to support UHS-I modes

Changes since v1:
- squashed the two patches into one
- added performance logs for the above mentioned speed modes


Aswath Govindraju (1):
  arm64: dts: ti: k3-j7200: Add support for higher speed modes and
update delay select values for MMCSD subsystems

Faiz Abbas (2):
  arm64: dts: ti: k3-j7200: Add gpio nodes
  arm64: dts: ti: k3-j7200-common-proc-board: Disable unused gpio
modules

 .../dts/ti/k3-j7200-common-proc-board.dts | 58 +
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 86 ++-
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi  | 34 
 3 files changed, 176 insertions(+), 2 deletions(-)

-- 
2.17.1



[PATCH v7 3/3] arm64: dts: ti: k3-j7200: Add support for higher speed modes and update delay select values for MMCSD subsystems

2021-03-22 Thread Aswath Govindraju
The following speed modes are now supported in J7200 SoC,
- HS200 and HS400 modes at 1.8 V card voltage, in MMCSD0 subsystem [1].
- UHS-I speed modes in MMCSD1 subsystem [1].

Add support for UHS-I modes by adding voltage regulator device tree nodes
and corresponding pinmux details, to power cycle and voltage switch cards.
Set respective tags in sdhci0 and remove no-1-8-v tag from sdhci1
device tree nodes.

Also update the delay values for various speed modes supported, based on
the revised january 2021 J7200 datasheet[2].

[1] - section 12.3.6.1.1 MMCSD Features, in
  https://www.ti.com/lit/ug/spruiu1a/spruiu1a.pdf,
  (SPRUIU1A – JULY 2020 – REVISED JANUARY 2021)

[2] - https://www.ti.com/lit/ds/symlink/dra821u.pdf,
  (SPRSP57B – APRIL 2020 – REVISED JANUARY 2021)

Signed-off-by: Aswath Govindraju 
---
 .../dts/ti/k3-j7200-common-proc-board.dts | 42 +++
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 14 ++-
 2 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
index b493f939b09a..de8c06bdc825 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
@@ -16,6 +16,29 @@
stdout-path = "serial2:115200n8";
bootargs = "console=ttyS2,115200n8 
earlycon=ns16550a,mmio32,0x0280";
};
+
+   vdd_mmc1: fixedregulator-sd {
+   compatible = "regulator-fixed";
+   regulator-name = "vdd_mmc1";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   enable-active-high;
+   gpios = < 2 GPIO_ACTIVE_HIGH>;
+   };
+
+   vdd_sd_dv: gpio-regulator-vdd-sd-dv {
+   compatible = "regulator-gpio";
+   regulator-name = "vdd_sd_dv";
+   pinctrl-names = "default";
+   pinctrl-0 = <_sd_dv_pins_default>;
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   gpios = <_gpio0 55 GPIO_ACTIVE_HIGH>;
+   states = <180 0x0
+ 330 0x1>;
+   };
 };
 
 _pmx0 {
@@ -45,6 +68,13 @@
 };
 
 _pmx0 {
+   main_i2c0_pins_default: main-i2c0-pins-default {
+   pinctrl-single,pins = <
+   J721E_IOPAD(0xd4, PIN_INPUT_PULLUP, 0) /* (V3) I2C0_SCL 
*/
+   J721E_IOPAD(0xd8, PIN_INPUT_PULLUP, 0) /* (W2) I2C0_SDA 
*/
+   >;
+   };
+
main_i2c1_pins_default: main-i2c1-pins-default {
pinctrl-single,pins = <
J721E_IOPAD(0xdc, PIN_INPUT_PULLUP, 3) /* (U3) 
ECAP0_IN_APWM_OUT.I2C1_SCL */
@@ -70,6 +100,12 @@
J721E_IOPAD(0x120, PIN_OUTPUT, 0) /* (T4) USB0_DRVVBUS 
*/
>;
};
+
+   vdd_sd_dv_pins_default: vdd-sd-dv-pins-default {
+   pinctrl-single,pins = <
+   J721E_IOPAD(0xd0, PIN_INPUT, 7) /* (T5) 
SPI0_D1.GPIO0_55 */
+   >;
+   };
 };
 
 _uart0 {
@@ -157,6 +193,10 @@
 };
 
 _i2c0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <_i2c0_pins_default>;
+   clock-frequency = <40>;
+
exp1: gpio@20 {
compatible = "ti,tca6416";
reg = <0x20>;
@@ -206,6 +246,8 @@
/* SD card */
pinctrl-0 = <_mmc1_pins_default>;
pinctrl-names = "default";
+   vmmc-supply = <_mmc1>;
+   vqmmc-supply = <_sd_dv>;
ti,driver-strength-ohm = <50>;
disable-wp;
 };
diff --git a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
index e60650a62b14..f86c493a44f1 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
@@ -512,11 +512,16 @@
ti,otap-del-sel-mmc-hs = <0x0>;
ti,otap-del-sel-ddr52 = <0x6>;
ti,otap-del-sel-hs200 = <0x8>;
-   ti,otap-del-sel-hs400 = <0x0>;
+   ti,otap-del-sel-hs400 = <0x5>;
+   ti,itap-del-sel-legacy = <0x10>;
+   ti,itap-del-sel-mmc-hs = <0xa>;
ti,strobe-sel = <0x77>;
+   ti,clkbuf-sel = <0x7>;
ti,trm-icp = <0x8>;
bus-width = <8>;
mmc-ddr-1_8v;
+   mmc-hs200-1_8v;
+   mmc-hs400-1_8v;
dma-coherent;
};
 
@@ -534,7 +539,12 @@
ti,otap-del-sel-sdr50 = <0xc>;
ti,o

[PATCH 1/2] arm64: dts: ti: k3-am64: Add SERDES DT node

2021-03-19 Thread Aswath Govindraju
From: Kishon Vijay Abraham I 

Add SERDES DT node for the single one lane SERDES present in
AM64.

Signed-off-by: Kishon Vijay Abraham I 
Signed-off-by: Aswath Govindraju 
---
 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 52 
 1 file changed, 52 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
index a03b66456062..5a62a96c048c 100644
--- a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
@@ -5,6 +5,17 @@
  * Copyright (C) 2020-2021 Texas Instruments Incorporated - https://www.ti.com/
  */
 
+#include 
+#include 
+
+/ {
+   serdes_refclk: serdes-refclk {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   clock-frequency = <1>;
+   };
+};
+
 _main {
oc_sram: sram@7000 {
compatible = "mmio-sram";
@@ -184,6 +195,12 @@
reg = <0x4044 0x8>;
#phy-cells = <1>;
};
+
+   serdes_ln_ctrl: mux {
+   compatible = "mmio-mux";
+   #mux-control-cells = <1>;
+   mux-reg-masks = <0x4080 0x3>; /* SERDES0 lane0 select */
+   };
};
 
main_uart0: serial@280 {
@@ -477,6 +494,41 @@
};
};
 
+   serdes_wiz0: wiz@f00 {
+   compatible = "ti,am64-wiz-10g";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   power-domains = <_pds 162 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 162 0>, <_clks 162 1>, <_refclk>;
+   clock-names = "fck", "core_ref_clk", "ext_ref_clk";
+   num-lanes = <1>;
+   #reset-cells = <1>;
+   #clock-cells = <1>;
+   ranges = <0x0f00 0x0 0x0f00 0x0001>;
+   assigned-clocks = <_clks 162 1>;
+   assigned-clock-parents = <_clks 162 5>;
+
+   serdes0: serdes@f00 {
+   compatible = "ti,j721e-serdes-10g";
+   reg = <0x0f00 0x0001>;
+   reg-names = "torrent_phy";
+   resets = <_wiz0 0>;
+   reset-names = "torrent_reset";
+   clocks = <_wiz0 TI_WIZ_PLL0_REFCLK>,
+<_wiz0 TI_WIZ_PHY_EN_REFCLK>;
+   clock-names = "refclk", "phy_en_refclk";
+   assigned-clocks = <_wiz0 TI_WIZ_PLL0_REFCLK>,
+ <_wiz0 TI_WIZ_PLL1_REFCLK>,
+ <_wiz0 TI_WIZ_REFCLK_DIG>;
+   assigned-clock-parents = <_clks 162 1>,
+<_clks 162 1>,
+<_clks 162 1>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   #clock-cells = <1>;
+   };
+   };
+
cpts@3900 {
compatible = "ti,j721e-cpts";
reg = <0x0 0x3900 0x0 0x400>;
-- 
2.17.1



[PATCH 2/2] arm64: dts: ti: k3-am642-sk: Enable USB Super-Speed HOST port

2021-03-19 Thread Aswath Govindraju
From: Kishon Vijay Abraham I 

Enable USB Super-Speed HOST port.

Signed-off-by: Kishon Vijay Abraham I 
Signed-off-by: Aswath Govindraju 
---
 arch/arm64/boot/dts/ti/k3-am642-sk.dts | 39 ++
 1 file changed, 39 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am642-sk.dts 
b/arch/arm64/boot/dts/ti/k3-am642-sk.dts
index 3a5bee4b0b0c..f193ec630d18 100644
--- a/arch/arm64/boot/dts/ti/k3-am642-sk.dts
+++ b/arch/arm64/boot/dts/ti/k3-am642-sk.dts
@@ -5,6 +5,8 @@
 
 /dts-v1/;
 
+#include 
+#include 
 #include 
 #include 
 #include "k3-am642.dtsi"
@@ -85,6 +87,12 @@
>;
};
 
+   main_usb0_pins_default: main-usb0-pins-default {
+   pinctrl-single,pins = <
+   AM64X_IOPAD(0x02a8, PIN_OUTPUT, 0) /* (E19) 
USB0_DRVVBUS */
+   >;
+   };
+
main_i2c1_pins_default: main-i2c1-pins-default {
pinctrl-single,pins = <
AM64X_IOPAD(0x0268, PIN_INPUT_PULLUP, 0) /* (C18) 
I2C1_SCL */
@@ -230,6 +238,37 @@
disable-wp;
 };
 
+_ln_ctrl {
+   idle-states = ;
+};
+
+_wiz0 {
+   status = "okay";
+};
+
+ {
+   serdes0_usb_link: phy@0 {
+   reg = <0>;
+   cdns,num-lanes = <1>;
+   #phy-cells = <0>;
+   cdns,phy-type = ;
+   resets = <_wiz0 1>;
+   };
+};
+
+ {
+   ti,vbus-divider;
+};
+
+ {
+   dr_mode = "host";
+   maximum-speed = "super-speed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_usb0_pins_default>;
+   phys = <_usb_link>;
+   phy-names = "cdns3,usb3-phy";
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_pins_default
-- 
2.17.1



[PATCH 0/2] AM642-sk: Add support for USB

2021-03-19 Thread Aswath Govindraju
The following series of patches add support for,
- single one lane SERDES present in AM64
- USB super-speed port on AM642-sk

USB test logs,
https://pastebin.ubuntu.com/p/4RT9Y94fPv/

The following patches depend on,
1) - 
https://lore.kernel.org/linux-devicetree/20210310112745.3445-1-kis...@ti.com/
 binding additions and given below is an immutable tag  provided by
 Vinod Koul  (one of the Maintainers of GENERIC PHY
 FRAMEWORK) after applying them,

 git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy.git
 tags/ti-serdes-for-5.13

2) - https://patchwork.kernel.org/project/linux-phy/list/?series=445371
 Serdes driver changes required for USB super-speed functionality.

Kishon Vijay Abraham I (2):
  arm64: dts: ti: k3-am64: Add SERDES DT node
  arm64: dts: ti: k3-am642-sk: Enable USB Super-Speed HOST port

 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 52 
 arch/arm64/boot/dts/ti/k3-am642-sk.dts   | 39 ++
 2 files changed, 91 insertions(+)

-- 
2.17.1



Re: [PATCH v2 0/2] AM64: Add support for GPIO

2021-03-18 Thread Aswath Govindraju
Hi Nishanth,

On 09/03/21 9:28 pm, Nishanth Menon wrote:
> On 21:20-20210309, Aswath Govindraju wrote:
>> Hi Nishanth,
>>
>> On 09/03/21 8:13 pm, Nishanth Menon wrote:
>>> On 16:59-20210304, Aswath Govindraju wrote:
>>>> The following series of patches adds support for gpio on AM642 evm/sk.
>>>>
>>>> Changes since v1:
>>>> - Added DT for gpio subsystem present in MCU domain
>>>> - reserved the mcu gpio for firmware usage
>>>>
>>>> This series of patches depend on,
>>>> https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=439039
>>>> https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=439153
>>>>
>>>>
>>>> Aswath Govindraju (2):
>>>>   arm64: dts: ti: k3-am64: Add GPIO DT nodes
>>>>   arm64: dts: ti: k3-am642: reserve gpio in mcu domain for firmware
>>>> usage
>>>>
>>>>  arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 45 
>>>>  arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi  | 27 ++
>>>>  arch/arm64/boot/dts/ti/k3-am642-evm.dts  |  5 +++
>>>>  arch/arm64/boot/dts/ti/k3-am642-sk.dts   |  5 +++
>>>>  4 files changed, 82 insertions(+)
>>>>
>>>> -- 
>>>> 2.17.1
>>>>
>>>
>>>
>>> Based on your offline comment:
>>> -
>>>
>>> On going through the bootlogs before posting for I found the following
>>> errors,
>>>
>>> [1.091117] davinci_gpio 601000.gpio: IRQ index 2 not found
>>> [1.101522] davinci_gpio 601000.gpio: error -ENXIO: IRQ not populated
>>>
>>> Some issues in allocating interrupts in case of main_gpio1. I
>>> accumulated the gpio with interrupt numbers. I'll try to debug the
>>> reason behind it and update you with its status. (bootlogs of ti-sdk,
>>> also have this error).
>>>
>>> -
>>>
>>> I am going to drop this off my queue, please update if the fixup is some
>>> system configuration error or repost with fix.
>>>
>>
>> This is expected to be a fixup in the system configuration and not a bug
>> in the patch series. So, can you please have these patches in your queue
>> ? I'll soon post the test results indicating the functioning of GPIOs.
> 
> 
> Thanks for clarifying. I will wait till the test results are posted.
> Thanks in advance for digging into this and detailed testing.
> 

I've posted a respin(v3) of this series after rebasing on top of
ti-k3-dts-next branch and adding the GPIO test logs.

Thanks,
Aswath


[PATCH v3 1/2] arm64: dts: ti: k3-am64: Add GPIO DT nodes

2021-03-18 Thread Aswath Govindraju
Add device tree nodes for GPIO modules and interrupt controller in main
and mcu domains.

Signed-off-by: Aswath Govindraju 
---
 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 45 
 arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi  | 27 ++
 2 files changed, 72 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
index a03b66456062..b997d13f9ec5 100644
--- a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
@@ -373,6 +373,51 @@
clocks = <_clks 145 0>;
};
 
+   main_gpio_intr: interrupt-controller0 {
+   compatible = "ti,sci-intr";
+   ti,intr-trigger-type = <1>;
+   interrupt-controller;
+   interrupt-parent = <>;
+   #interrupt-cells = <1>;
+   ti,sci = <>;
+   ti,sci-dev-id = <3>;
+   ti,interrupt-ranges = <0 32 16>;
+   };
+
+   main_gpio0: gpio@60 {
+   compatible = "ti,am64-gpio", "ti,keystone-gpio";
+   reg = <0x0 0x0060 0x0 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <190>, <191>, <192>,
+<193>, <194>, <195>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   ti,ngpio = <87>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 77 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 77 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio1: gpio@601000 {
+   compatible = "ti,am64-gpio", "ti,keystone-gpio";
+   reg = <0x0 0x00601000 0x0 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <180>, <181>, <182>,
+<183>, <184>, <185>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   ti,ngpio = <88>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 78 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 78 0>;
+   clock-names = "gpio";
+   };
+
sdhci0: mmc@fa1 {
compatible = "ti,am64-sdhci-8bit";
reg = <0x00 0xfa1 0x00 0x260>, <0x00 0xfa18000 0x00 0x134>;
diff --git a/arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi 
b/arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi
index 1d2be485a669..99e94dee1bd4 100644
--- a/arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi
@@ -73,4 +73,31 @@
power-domains = <_pds 148 TI_SCI_PD_EXCLUSIVE>;
clocks = <_clks 148 0>;
};
+
+   mcu_gpio_intr: interrupt-controller1 {
+   compatible = "ti,sci-intr";
+   ti,intr-trigger-type = <1>;
+   interrupt-controller;
+   interrupt-parent = <>;
+   #interrupt-cells = <1>;
+   ti,sci = <>;
+   ti,sci-dev-id = <5>;
+   ti,interrupt-ranges = <0 104 4>;
+   };
+
+   mcu_gpio0: gpio@4201000 {
+   compatible = "ti,am64-gpio", "keystone-gpio";
+   reg = <0x0 0x4201000 0x0 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <30>, <31>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   ti,ngpio = <23>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 79 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 79 0>;
+   clock-names = "gpio";
+   };
 };
-- 
2.17.1



[PATCH v3 2/2] arm64: dts: ti: k3-am642: reserve gpio in mcu domain for firmware usage

2021-03-18 Thread Aswath Govindraju
The gpio0 subsystem present in MCU domain might be used by firmware and is
not pinned out in evm/sk. Therefore, reserve it for MCU firmware.

Signed-off-by: Aswath Govindraju 
---
 arch/arm64/boot/dts/ti/k3-am642-evm.dts | 5 +
 arch/arm64/boot/dts/ti/k3-am642-sk.dts  | 5 +
 2 files changed, 10 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am642-evm.dts 
b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
index 9522f104d979..385d99a3bc4f 100644
--- a/arch/arm64/boot/dts/ti/k3-am642-evm.dts
+++ b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
@@ -310,6 +310,11 @@
};
 };
 
+/* mcu_gpio0 is reserved for mcu firmware usage */
+_gpio0 {
+   status = "reserved";
+};
+
 _i2c0 {
status = "disabled";
 };
diff --git a/arch/arm64/boot/dts/ti/k3-am642-sk.dts 
b/arch/arm64/boot/dts/ti/k3-am642-sk.dts
index 3a5bee4b0b0c..282fb4185db9 100644
--- a/arch/arm64/boot/dts/ti/k3-am642-sk.dts
+++ b/arch/arm64/boot/dts/ti/k3-am642-sk.dts
@@ -220,6 +220,11 @@
status = "disabled";
 };
 
+/* mcu_gpio0 is reserved for mcu firmware usage */
+_gpio0 {
+   status = "reserved";
+};
+
  {
/* SD/MMC */
vmmc-supply = <_mmc1>;
-- 
2.17.1



[PATCH v3 0/2] AM64: Add support for GPIO

2021-03-18 Thread Aswath Govindraju
The following series of patches adds support for gpio on AM642 evm/sk.

GPIO test logs,
AM642-evm: https://pastebin.ubuntu.com/p/PCGmY34spb/
AM642-sk:  https://pastebin.ubuntu.com/p/nrxzyQTKkX/

Changes since v2:
- Rebased the series on top of ti-k3-dts-next branch
- Added gpio test logs.

Changes since v1:
- Added DT for gpio subsystem present in MCU domain
- reserved the mcu gpio for firmware usage

Aswath Govindraju (2):
  arm64: dts: ti: k3-am64: Add GPIO DT nodes
  arm64: dts: ti: k3-am642: reserve gpio in mcu domain for firmware
usage

 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 45 
 arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi  | 27 ++
 arch/arm64/boot/dts/ti/k3-am642-evm.dts  |  5 +++
 arch/arm64/boot/dts/ti/k3-am642-sk.dts   |  5 +++
 4 files changed, 82 insertions(+)

-- 
2.17.1



Re: [PATCH v5 3/3] arm64: dts: ti: k3-j7200: Add support for higher speed modes and update delay select values for MMCSD subsystems

2021-03-18 Thread Aswath Govindraju
Hi Kishon,

On 18/03/21 8:45 pm, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On 10/03/21 9:49 pm, Aswath Govindraju wrote:
>> The following speed modes are now supported in J7200 SoC,
>> - HS200 and HS400 modes at 1.8 V card voltage, in MMCSD0 subsystem [1].
>> - UHS-I speed modes in MMCSD1 subsystem [1].
>>
>> Add support for UHS-I modes by adding voltage regulator device tree nodes
>> and corresponding pinmux details, to power cycle and voltage switch cards.
>> Set respective tags in sdhci0 and remove no-1-8-v tag from sdhci1
>> device tree nodes.
>>
>> Also update the delay values for various speed modes supported, based on
>> the latest J7200 datasheet[2]
> 
> nit: Better to mention the datasheet version (as it's not latest anymore).
>>
>> [1] - section 12.3.6.1.1 MMCSD Features, in
>>   https://www.ti.com/lit/ug/spruiu1a/spruiu1a.pdf
>>
>> [2] - https://www.ti.com/lit/ds/symlink/dra821a.pdf
> > Er.. this link is already broken.
> 

Sorry, fixed this and added the version information for references in
the respin(v6) of this series.

Thank you for the comments.

Regards,
Aswath

> Thanks
> Kishon
>>
>> Signed-off-by: Aswath Govindraju 
>> ---
>>  .../dts/ti/k3-j7200-common-proc-board.dts | 42 +++
>>  arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 14 ++-
>>  2 files changed, 54 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
>> b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>> index b493f939b09a..6f90c3b1cf45 100644
>> --- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>> +++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>> @@ -16,6 +16,29 @@
>>  stdout-path = "serial2:115200n8";
>>  bootargs = "console=ttyS2,115200n8 
>> earlycon=ns16550a,mmio32,0x0280";
>>  };
>> +
>> +vdd_mmc1: fixedregulator-sd {
>> +compatible = "regulator-fixed";
>> +regulator-name = "vdd_mmc1";
>> +regulator-min-microvolt = <330>;
>> +regulator-max-microvolt = <330>;
>> +regulator-boot-on;
>> +enable-active-high;
>> +gpios = < 2 GPIO_ACTIVE_HIGH>;
>> +};
>> +
>> +vdd_sd_dv: gpio-regulator-vdd-sd-dv {
>> +compatible = "regulator-gpio";
>> +regulator-name = "vdd_sd_dv";
>> +pinctrl-names = "default";
>> +pinctrl-0 = <_sd_dv_pins_default>;
>> +regulator-min-microvolt = <180>;
>> +regulator-max-microvolt = <330>;
>> +regulator-boot-on;
>> +gpios = <_gpio0 55 GPIO_ACTIVE_HIGH>;
>> +states = <180 0x0
>> +  330 0x1>;
>> +};
>>  };
>>  
>>  _pmx0 {
>> @@ -45,6 +68,13 @@
>>  };
>>  
>>  _pmx0 {
>> +main_i2c0_pins_default: main-i2c0-pins-default {
>> +pinctrl-single,pins = <
>> +J721E_IOPAD(0xd4, PIN_INPUT_PULLUP, 0) /* (V3) I2C0_SCL 
>> */
>> +J721E_IOPAD(0xd8, PIN_INPUT_PULLUP, 0) /* (W2) I2C0_SDA 
>> */
>> +>;
>> +};
>> +
>>  main_i2c1_pins_default: main-i2c1-pins-default {
>>  pinctrl-single,pins = <
>>  J721E_IOPAD(0xdc, PIN_INPUT_PULLUP, 3) /* (U3) 
>> ECAP0_IN_APWM_OUT.I2C1_SCL */
>> @@ -70,6 +100,12 @@
>>  J721E_IOPAD(0x120, PIN_OUTPUT, 0) /* (T4) USB0_DRVVBUS 
>> */
>>  >;
>>  };
>> +
>> +vdd_sd_dv_pins_default: vdd_sd_dv_pins_default {
>> +pinctrl-single,pins = <
>> +J721E_IOPAD(0xd0, PIN_INPUT, 7) /* (T5) 
>> SPI0_D1.GPIO0_55 */
>> +>;
>> +};
>>  };
>>  
>>  _uart0 {
>> @@ -157,6 +193,10 @@
>>  };
>>  
>>  _i2c0 {
>> +pinctrl-names = "default";
>> +pinctrl-0 = <_i2c0_pins_default>;
>> +clock-frequency = <40>;
>> +
>>  exp1: gpio@20 {
>>  compatible = "ti,tca6416";
>>  reg = <0x20>;
>> @@ -206,6 +246,8 @@
>>  /* SD card */
>>  pinctrl-0 = <_mmc1_pins_default>;
>>  pinctrl-names = "default";
>> +vmmc-supply = <_mmc1>;
>> +vq

[PATCH v6 1/3] arm64: dts: ti: k3-j7200: Add gpio nodes

2021-03-18 Thread Aswath Govindraju
From: Faiz Abbas 

There are 4 instances of gpio modules in main domain:
gpio0, gpio2, gpio4 and gpio6

Groups are created to provide protection between different processor
virtual worlds. Each of these modules I/O pins are muxed within the
group. Exactly one module can be selected to control the corresponding
pin by selecting it in the pad mux configuration registers.

This group in main domain pins out 69 lines (5 banks). Add DT modes for
each module instance in the main domain.

Similar to the gpio groups in main domain, there is one gpio group in
wakeup domain with 2 module instances in it.

The gpio group pins out 72 pins (6 banks) of the first 85 gpio lines. Add
DT nodes for each module instance in the wakeup domain.

Signed-off-by: Faiz Abbas 
Signed-off-by: Sekhar Nori 
Signed-off-by: Aswath Govindraju 
Reviewed-by: Grygorii Strashko 
---
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 72 +++
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi  | 34 +
 2 files changed, 106 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
index 17477ab0fd8e..e60650a62b14 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
@@ -672,6 +672,78 @@
};
};
 
+   main_gpio0: gpio@60 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0060 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <145>, <146>, <147>, <148>,
+<149>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 105 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 105 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio2: gpio@61 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0061 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <154>, <155>, <156>, <157>,
+<158>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 107 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 107 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio4: gpio@62 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0062 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <163>, <164>, <165>, <166>,
+<167>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 109 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 109 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio6: gpio@63 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0063 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <172>, <173>, <174>, <175>,
+<176>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 111 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 111 0>;
+   clock-names = "gpio";
+   };
+
main_r5fss0: r5fss@5c0 {
compatible = "ti,j7200-r5fss";
ti,cluster-mode = <1>;
diff --git a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
index 359e3e8a8cd0..1dd5b30edc6c 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
+++ b/

[PATCH v6 3/3] arm64: dts: ti: k3-j7200: Add support for higher speed modes and update delay select values for MMCSD subsystems

2021-03-18 Thread Aswath Govindraju
The following speed modes are now supported in J7200 SoC,
- HS200 and HS400 modes at 1.8 V card voltage, in MMCSD0 subsystem [1].
- UHS-I speed modes in MMCSD1 subsystem [1].

Add support for UHS-I modes by adding voltage regulator device tree nodes
and corresponding pinmux details, to power cycle and voltage switch cards.
Set respective tags in sdhci0 and remove no-1-8-v tag from sdhci1
device tree nodes.

Also update the delay values for various speed modes supported, based on
the revised january 2021 J7200 datasheet[2].

[1] - section 12.3.6.1.1 MMCSD Features, in
  https://www.ti.com/lit/ug/spruiu1a/spruiu1a.pdf,
  (SPRUIU1A – JULY 2020 – REVISED JANUARY 2021)

[2] - https://www.ti.com/lit/ds/symlink/dra821u.pdf,
  (SPRSP57B – APRIL 2020 – REVISED JANUARY 2021)

Signed-off-by: Aswath Govindraju 
---
 .../dts/ti/k3-j7200-common-proc-board.dts | 42 +++
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 14 ++-
 2 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
index b493f939b09a..6f90c3b1cf45 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
@@ -16,6 +16,29 @@
stdout-path = "serial2:115200n8";
bootargs = "console=ttyS2,115200n8 
earlycon=ns16550a,mmio32,0x0280";
};
+
+   vdd_mmc1: fixedregulator-sd {
+   compatible = "regulator-fixed";
+   regulator-name = "vdd_mmc1";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   enable-active-high;
+   gpios = < 2 GPIO_ACTIVE_HIGH>;
+   };
+
+   vdd_sd_dv: gpio-regulator-vdd-sd-dv {
+   compatible = "regulator-gpio";
+   regulator-name = "vdd_sd_dv";
+   pinctrl-names = "default";
+   pinctrl-0 = <_sd_dv_pins_default>;
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   gpios = <_gpio0 55 GPIO_ACTIVE_HIGH>;
+   states = <180 0x0
+ 330 0x1>;
+   };
 };
 
 _pmx0 {
@@ -45,6 +68,13 @@
 };
 
 _pmx0 {
+   main_i2c0_pins_default: main-i2c0-pins-default {
+   pinctrl-single,pins = <
+   J721E_IOPAD(0xd4, PIN_INPUT_PULLUP, 0) /* (V3) I2C0_SCL 
*/
+   J721E_IOPAD(0xd8, PIN_INPUT_PULLUP, 0) /* (W2) I2C0_SDA 
*/
+   >;
+   };
+
main_i2c1_pins_default: main-i2c1-pins-default {
pinctrl-single,pins = <
J721E_IOPAD(0xdc, PIN_INPUT_PULLUP, 3) /* (U3) 
ECAP0_IN_APWM_OUT.I2C1_SCL */
@@ -70,6 +100,12 @@
J721E_IOPAD(0x120, PIN_OUTPUT, 0) /* (T4) USB0_DRVVBUS 
*/
>;
};
+
+   vdd_sd_dv_pins_default: vdd_sd_dv_pins_default {
+   pinctrl-single,pins = <
+   J721E_IOPAD(0xd0, PIN_INPUT, 7) /* (T5) 
SPI0_D1.GPIO0_55 */
+   >;
+   };
 };
 
 _uart0 {
@@ -157,6 +193,10 @@
 };
 
 _i2c0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <_i2c0_pins_default>;
+   clock-frequency = <40>;
+
exp1: gpio@20 {
compatible = "ti,tca6416";
reg = <0x20>;
@@ -206,6 +246,8 @@
/* SD card */
pinctrl-0 = <_mmc1_pins_default>;
pinctrl-names = "default";
+   vmmc-supply = <_mmc1>;
+   vqmmc-supply = <_sd_dv>;
ti,driver-strength-ohm = <50>;
disable-wp;
 };
diff --git a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
index e60650a62b14..f86c493a44f1 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
@@ -512,11 +512,16 @@
ti,otap-del-sel-mmc-hs = <0x0>;
ti,otap-del-sel-ddr52 = <0x6>;
ti,otap-del-sel-hs200 = <0x8>;
-   ti,otap-del-sel-hs400 = <0x0>;
+   ti,otap-del-sel-hs400 = <0x5>;
+   ti,itap-del-sel-legacy = <0x10>;
+   ti,itap-del-sel-mmc-hs = <0xa>;
ti,strobe-sel = <0x77>;
+   ti,clkbuf-sel = <0x7>;
ti,trm-icp = <0x8>;
bus-width = <8>;
mmc-ddr-1_8v;
+   mmc-hs200-1_8v;
+   mmc-hs400-1_8v;
dma-coherent;
};
 
@@ -534,7 +539,12 @@
ti,otap-del-sel-sdr50 = <0xc>;
ti,o

[PATCH v6 0/3] J7200: Add support for GPIO and higher speed modes in MMCSD subsystems

2021-03-18 Thread Aswath Govindraju
The following series of patches
- Add support for GPIO subsystem in main and wakeup domains.
- Add voltage regulator device tree nodes and their corresponding pinmux
  to support power cycle and voltage switch required for UHS-I modes
- sets respective tags in sdhci0 node to support higher speeds
- remove no-1-8-v tag from sdhci1 node to support UHS-I modes
- Update delay values for various speed modes supported.


test logs
- eMMC HS400 speed mode
https://pastebin.ubuntu.com/p/xqZt34mRWf/

- SD SDR104 speed mode
https://pastebin.ubuntu.com/p/qM2H85SQvX/

- GPIO logs
https://pastebin.ubuntu.com/p/7WXdRxxdWz/


Changes since v5:
- Corrected the link in patch 3 as it broken.
- Added the version number for the references used in patch 3.
- picked up reviewed-by from gyrgorii for patches 1 and 2.

Changes since v4:
- Added main_i2c0 pinmux required for doing power cycles to MMCSD1
  subsystem
- Updated delay values for various speed modes supported
- Corrected the ti,ngpio property to indicate highest gpio lines that
  can be accessed.
- Reran the performace tests

Changes since v3:
- Removed patch (1 in v3).
- Rebased and included patches that add support for GPIO from series [1].
- Re-ran the performace tests for SD and eMMC.

Changes since v2:
- Added main_gpio0 DT node
- Added voltage regulator device tree nodes required to support UHS-I modes

Changes since v1:
- squashed the two patches into one
- added performance logs for the above mentioned speed modes

Aswath Govindraju (1):
  arm64: dts: ti: k3-j7200: Add support for higher speed modes and
update delay select values for MMCSD subsystems

Faiz Abbas (2):
  arm64: dts: ti: k3-j7200: Add gpio nodes
  arm64: dts: ti: k3-j7200-common-proc-board: Disable unused gpio
modules

 .../dts/ti/k3-j7200-common-proc-board.dts | 58 +
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 86 ++-
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi  | 34 
 3 files changed, 176 insertions(+), 2 deletions(-)

-- 
2.17.1



[PATCH v6 2/3] arm64: dts: ti: k3-j7200-common-proc-board: Disable unused gpio modules

2021-03-18 Thread Aswath Govindraju
From: Faiz Abbas 

There are 6 gpio instances inside SoC with 2 groups as show below:
Group one: wkup_gpio0, wkup_gpio1
Group two: main_gpio0, main_gpio2, main_gpio4, main_gpio6

Only one instance from each group can be used at a time. So use main_gpio0
and wkup_gpio0 in current linux context and disable the rest of the nodes.

Signed-off-by: Faiz Abbas 
Signed-off-by: Sekhar Nori 
Signed-off-by: Aswath Govindraju 
Reviewed-by: Grygorii Strashko 
---
 .../boot/dts/ti/k3-j7200-common-proc-board.dts   | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
index 4a7182abccf5..b493f939b09a 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
@@ -122,6 +122,22 @@
status = "disabled";
 };
 
+_gpio2 {
+   status = "disabled";
+};
+
+_gpio4 {
+   status = "disabled";
+};
+
+_gpio6 {
+   status = "disabled";
+};
+
+_gpio1 {
+   status = "disabled";
+};
+
 _cpsw {
pinctrl-names = "default";
pinctrl-0 = <_cpsw_pins_default _mdio_pins_default>;
-- 
2.17.1



[PATCH v3 2/2] arm64: dts: ti: k3-am642-evm: Add USB support

2021-03-16 Thread Aswath Govindraju
AM64 EVM board has a micro USB 2.0 AB connector and the USB0_VBUS is
connected with a resistor divider in between. USB0_DRVVBUS pin is muxed
between USB0_DRVVBUS and GPIO1_79 signals.

Add the corresponding properties and set the pinmux mode for USB subsystem
in the evm dts file.

Signed-off-by: Aswath Govindraju 
Acked-by: Roger Quadros 
---
 arch/arm64/boot/dts/ti/k3-am642-evm.dts | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am642-evm.dts 
b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
index 25fa6fbc0619..1365e3164294 100644
--- a/arch/arm64/boot/dts/ti/k3-am642-evm.dts
+++ b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
@@ -210,6 +210,12 @@
AM64X_IOPAD(0x0144, PIN_OUTPUT, 4) /* (Y11) 
PRG1_PRU1_GPO15.RGMII2_TX_CTL */
>;
};
+
+   main_usb0_pins_default: main-usb0-pins-default {
+   pinctrl-single,pins = <
+   AM64X_IOPAD(0x02a8, PIN_OUTPUT, 0) /* (E19) 
USB0_DRVVBUS */
+   >;
+   };
 };
 
 _uart0 {
@@ -335,6 +341,18 @@
disable-wp;
 };
 
+ {
+   ti,vbus-divider;
+   ti,usb2-only;
+};
+
+ {
+   dr_mode = "otg";
+   maximum-speed = "high-speed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_usb0_pins_default>;
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_pins_default
-- 
2.17.1



[PATCH v3 1/2] arm64: dts: ti: k3-am64-main: Add DT node for USB subsystem

2021-03-16 Thread Aswath Govindraju
Add DT node for the single USB subsystem in main dtsi file.

Signed-off-by: Aswath Govindraju 
Acked-by: Roger Quadros 
---
 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 30 
 1 file changed, 30 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
index 0cf727e3d1e2..7e7997e3adff 100644
--- a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
@@ -491,4 +491,34 @@
ti,cpts-periodic-outputs = <6>;
ti,cpts-ext-ts-inputs = <8>;
};
+
+   usbss0: cdns-usb@f90{
+   compatible = "ti,am64-usb";
+   reg = <0x00 0xf90 0x00 0x100>;
+   power-domains = <_pds 161 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 161 9>, <_clks 161 1>;
+   clock-names = "ref", "lpm";
+   assigned-clocks = <_clks 161 9>; /* USB2_REFCLK */
+   assigned-clock-parents = <_clks 161 10>; /* HF0SC0 */
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   usb0: usb@f40{
+   compatible = "cdns,usb3";
+   reg = <0x00 0xf40 0x00 0x1>,
+ <0x00 0xf41 0x00 0x1>,
+ <0x00 0xf42 0x00 0x1>;
+   reg-names = "otg",
+   "xhci",
+   "dev";
+   interrupts = , /* 
irq.0 */
+, /* 
irq.6 */
+; /* 
otgirq */
+   interrupt-names = "host",
+ "peripheral",
+ "otg";
+   maximum-speed = "super-speed";
+   dr_mode = "otg";
+   };
+   };
 };
-- 
2.17.1



[PATCH v3 0/2] AM64: Add USB support

2021-03-16 Thread Aswath Govindraju
The following series of patches, add USB support for AM642 evm.

USB test logs,
https://pastebin.ubuntu.com/p/YSQRBWGmzd/

Changes since v2:
- dropped compatible string "ti,j721e-usb" leading to DT schema errors
- Reran test logs
- Couldn't pick up reviewed-by from kishon as a change was made in the
  patch

Changes since v1:
- Rebased the patches on top of ti-k3-dts-next
- Added test logs

Aswath Govindraju (2):
  arm64: dts: ti: k3-am64-main: Add DT node for USB subsystem
  arm64: dts: ti: k3-am642-evm: Add USB support

 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 30 
 arch/arm64/boot/dts/ti/k3-am642-evm.dts  | 18 ++
 2 files changed, 48 insertions(+)

-- 
2.17.1



[PATCH v5 3/3] arm64: dts: ti: k3-j7200: Add support for higher speed modes and update delay select values for MMCSD subsystems

2021-03-10 Thread Aswath Govindraju
The following speed modes are now supported in J7200 SoC,
- HS200 and HS400 modes at 1.8 V card voltage, in MMCSD0 subsystem [1].
- UHS-I speed modes in MMCSD1 subsystem [1].

Add support for UHS-I modes by adding voltage regulator device tree nodes
and corresponding pinmux details, to power cycle and voltage switch cards.
Set respective tags in sdhci0 and remove no-1-8-v tag from sdhci1
device tree nodes.

Also update the delay values for various speed modes supported, based on
the latest J7200 datasheet[2]

[1] - section 12.3.6.1.1 MMCSD Features, in
  https://www.ti.com/lit/ug/spruiu1a/spruiu1a.pdf

[2] - https://www.ti.com/lit/ds/symlink/dra821a.pdf

Signed-off-by: Aswath Govindraju 
---
 .../dts/ti/k3-j7200-common-proc-board.dts | 42 +++
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 14 ++-
 2 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
index b493f939b09a..6f90c3b1cf45 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
@@ -16,6 +16,29 @@
stdout-path = "serial2:115200n8";
bootargs = "console=ttyS2,115200n8 
earlycon=ns16550a,mmio32,0x0280";
};
+
+   vdd_mmc1: fixedregulator-sd {
+   compatible = "regulator-fixed";
+   regulator-name = "vdd_mmc1";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   enable-active-high;
+   gpios = < 2 GPIO_ACTIVE_HIGH>;
+   };
+
+   vdd_sd_dv: gpio-regulator-vdd-sd-dv {
+   compatible = "regulator-gpio";
+   regulator-name = "vdd_sd_dv";
+   pinctrl-names = "default";
+   pinctrl-0 = <_sd_dv_pins_default>;
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   gpios = <_gpio0 55 GPIO_ACTIVE_HIGH>;
+   states = <180 0x0
+ 330 0x1>;
+   };
 };
 
 _pmx0 {
@@ -45,6 +68,13 @@
 };
 
 _pmx0 {
+   main_i2c0_pins_default: main-i2c0-pins-default {
+   pinctrl-single,pins = <
+   J721E_IOPAD(0xd4, PIN_INPUT_PULLUP, 0) /* (V3) I2C0_SCL 
*/
+   J721E_IOPAD(0xd8, PIN_INPUT_PULLUP, 0) /* (W2) I2C0_SDA 
*/
+   >;
+   };
+
main_i2c1_pins_default: main-i2c1-pins-default {
pinctrl-single,pins = <
J721E_IOPAD(0xdc, PIN_INPUT_PULLUP, 3) /* (U3) 
ECAP0_IN_APWM_OUT.I2C1_SCL */
@@ -70,6 +100,12 @@
J721E_IOPAD(0x120, PIN_OUTPUT, 0) /* (T4) USB0_DRVVBUS 
*/
>;
};
+
+   vdd_sd_dv_pins_default: vdd_sd_dv_pins_default {
+   pinctrl-single,pins = <
+   J721E_IOPAD(0xd0, PIN_INPUT, 7) /* (T5) 
SPI0_D1.GPIO0_55 */
+   >;
+   };
 };
 
 _uart0 {
@@ -157,6 +193,10 @@
 };
 
 _i2c0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <_i2c0_pins_default>;
+   clock-frequency = <40>;
+
exp1: gpio@20 {
compatible = "ti,tca6416";
reg = <0x20>;
@@ -206,6 +246,8 @@
/* SD card */
pinctrl-0 = <_mmc1_pins_default>;
pinctrl-names = "default";
+   vmmc-supply = <_mmc1>;
+   vqmmc-supply = <_sd_dv>;
ti,driver-strength-ohm = <50>;
disable-wp;
 };
diff --git a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
index e60650a62b14..f86c493a44f1 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
@@ -512,11 +512,16 @@
ti,otap-del-sel-mmc-hs = <0x0>;
ti,otap-del-sel-ddr52 = <0x6>;
ti,otap-del-sel-hs200 = <0x8>;
-   ti,otap-del-sel-hs400 = <0x0>;
+   ti,otap-del-sel-hs400 = <0x5>;
+   ti,itap-del-sel-legacy = <0x10>;
+   ti,itap-del-sel-mmc-hs = <0xa>;
ti,strobe-sel = <0x77>;
+   ti,clkbuf-sel = <0x7>;
ti,trm-icp = <0x8>;
bus-width = <8>;
mmc-ddr-1_8v;
+   mmc-hs200-1_8v;
+   mmc-hs400-1_8v;
dma-coherent;
};
 
@@ -534,7 +539,12 @@
ti,otap-del-sel-sdr50 = <0xc>;
ti,otap-del-sel-sdr104 = <0x5>;
ti,otap-del-sel-ddr50 = <0xc>;
-   no-1-8-v;

[PATCH v5 2/3] arm64: dts: ti: k3-j7200-common-proc-board: Disable unused gpio modules

2021-03-10 Thread Aswath Govindraju
From: Faiz Abbas 

There are 6 gpio instances inside SoC with 2 groups as show below:
Group one: wkup_gpio0, wkup_gpio1
Group two: main_gpio0, main_gpio2, main_gpio4, main_gpio6

Only one instance from each group can be used at a time. So use main_gpio0
and wkup_gpio0 in current linux context and disable the rest of the nodes.

Signed-off-by: Faiz Abbas 
Signed-off-by: Sekhar Nori 
Signed-off-by: Aswath Govindraju 
---
 .../boot/dts/ti/k3-j7200-common-proc-board.dts   | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
index 4a7182abccf5..b493f939b09a 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
@@ -122,6 +122,22 @@
status = "disabled";
 };
 
+_gpio2 {
+   status = "disabled";
+};
+
+_gpio4 {
+   status = "disabled";
+};
+
+_gpio6 {
+   status = "disabled";
+};
+
+_gpio1 {
+   status = "disabled";
+};
+
 _cpsw {
pinctrl-names = "default";
pinctrl-0 = <_cpsw_pins_default _mdio_pins_default>;
-- 
2.17.1



[PATCH v5 1/3] arm64: dts: ti: k3-j7200: Add gpio nodes

2021-03-10 Thread Aswath Govindraju
From: Faiz Abbas 

There are 4 instances of gpio modules in main domain:
gpio0, gpio2, gpio4 and gpio6

Groups are created to provide protection between different processor
virtual worlds. Each of these modules I/O pins are muxed within the
group. Exactly one module can be selected to control the corresponding
pin by selecting it in the pad mux configuration registers.

This group in main domain pins out 69 lines (5 banks). Add DT modes for
each module instance in the main domain.

Similar to the gpio groups in main domain, there is one gpio group in
wakeup domain with 2 module instances in it.

The gpio group pins out 72 pins (6 banks) of the first 85 gpio lines. Add
DT nodes for each module instance in the wakeup domain.

Signed-off-by: Faiz Abbas 
Signed-off-by: Sekhar Nori 
Signed-off-by: Aswath Govindraju 
---
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 72 +++
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi  | 34 +
 2 files changed, 106 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
index 17477ab0fd8e..e60650a62b14 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j7200-main.dtsi
@@ -672,6 +672,78 @@
};
};
 
+   main_gpio0: gpio@60 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0060 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <145>, <146>, <147>, <148>,
+<149>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 105 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 105 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio2: gpio@61 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0061 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <154>, <155>, <156>, <157>,
+<158>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 107 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 107 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio4: gpio@62 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0062 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <163>, <164>, <165>, <166>,
+<167>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 109 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 109 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio6: gpio@63 {
+   compatible = "ti,j721e-gpio", "ti,keystone-gpio";
+   reg = <0x00 0x0063 0x00 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <172>, <173>, <174>, <175>,
+<176>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   #address-cells = <0>;
+   ti,ngpio = <69>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 111 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 111 0>;
+   clock-names = "gpio";
+   };
+
main_r5fss0: r5fss@5c0 {
compatible = "ti,j7200-r5fss";
ti,cluster-mode = <1>;
diff --git a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
index 359e3e8a8cd0..1dd5b30edc6c 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j7200-mcu-wak

[PATCH v5 0/3] J7200: Add support for GPIO and higher speed modes in MMCSD subsystems

2021-03-10 Thread Aswath Govindraju
The following series of patches
- Add support for GPIO subsystem in main and wakeup domains.
- Add voltage regulator device tree nodes and their corresponding pinmux
  to support power cycle and voltage switch required for UHS-I modes
- sets respective tags in sdhci0 node to support higher speeds
- remove no-1-8-v tag from sdhci1 node to support UHS-I modes
- Update delay values for various speed modes supported.


test logs
- eMMC HS400 speed mode
https://pastebin.ubuntu.com/p/xqZt34mRWf/

- SD SDR104 speed mode
https://pastebin.ubuntu.com/p/qM2H85SQvX/

- GPIO logs
https://pastebin.ubuntu.com/p/7WXdRxxdWz/


Changes since v4:
- Added main_i2c0 pinmux required for doing power cycles to MMCSD1
  subsystem
- Updated delay values for various speed modes supported
- Corrected the ti,ngpio property to indicate highest gpio lines that
  can be accessed.
- Reran the performace tests

Changes since v3:
- Removed patch (1 in v3).
- Rebased and included patches that add support for GPIO from series [1].
- Re-ran the performace tests for SD and eMMC.

Changes since v2:
- Added main_gpio0 DT node
- Added voltage regulator device tree nodes required to support UHS-I modes

Changes since v1:
- squashed the two patches into one
- added performance logs for the above mentioned speed modes

Aswath Govindraju (1):
  arm64: dts: ti: k3-j7200: Add support for higher speed modes and
update delay select values for MMCSD subsystems

Faiz Abbas (2):
  arm64: dts: ti: k3-j7200: Add gpio nodes
  arm64: dts: ti: k3-j7200-common-proc-board: Disable unused gpio
modules

 .../dts/ti/k3-j7200-common-proc-board.dts | 58 +
 arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 86 ++-
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi  | 34 
 3 files changed, 176 insertions(+), 2 deletions(-)

-- 
2.17.1



[PATCH v2 2/2] arm64: dts: ti: k3-am642-evm: Add USB support

2021-03-10 Thread Aswath Govindraju
AM64 EVM board has a micro USB 2.0 AB connector and the USB0_VBUS is
connected with a resistor divider in between. USB0_DRVVBUS pin is muxed
between USB0_DRVVBUS and GPIO1_79 signals.

Add the corresponding properties and set the pinmux mode for USB subsystem
in the evm dts file.

Signed-off-by: Aswath Govindraju 
Acked-by: Roger Quadros 
---
 arch/arm64/boot/dts/ti/k3-am642-evm.dts | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am642-evm.dts 
b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
index 962ef807e286..45fdcf3220a8 100644
--- a/arch/arm64/boot/dts/ti/k3-am642-evm.dts
+++ b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
@@ -201,6 +201,12 @@
AM64X_IOPAD(0x0144, PIN_OUTPUT, 4) /* (Y11) 
PRG1_PRU1_GPO15.RGMII2_TX_CTL */
>;
};
+
+   main_usb0_pins_default: main-usb0-pins-default {
+   pinctrl-single,pins = <
+   AM64X_IOPAD(0x02a8, PIN_OUTPUT, 0) /* (E19) 
USB0_DRVVBUS */
+   >;
+   };
 };
 
 _uart0 {
@@ -313,6 +319,18 @@
disable-wp;
 };
 
+ {
+   ti,vbus-divider;
+   ti,usb2-only;
+};
+
+ {
+   dr_mode = "otg";
+   maximum-speed = "high-speed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_usb0_pins_default>;
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_pins_default
-- 
2.17.1



[PATCH v2 1/2] arm64: dts: ti: k3-am64-main: Add DT node for USB subsystem

2021-03-10 Thread Aswath Govindraju
Add DT node for the single USB subsystem in main dtsi file.

Signed-off-by: Aswath Govindraju 
Acked-by: Roger Quadros 
---
 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 30 
 1 file changed, 30 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
index 0cf727e3d1e2..5979eb163dd1 100644
--- a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
@@ -491,4 +491,34 @@
ti,cpts-periodic-outputs = <6>;
ti,cpts-ext-ts-inputs = <8>;
};
+
+   usbss0: cdns-usb@f90{
+   compatible = "ti,am64-usb", "ti,j721e-usb";
+   reg = <0x00 0xf90 0x00 0x100>;
+   power-domains = <_pds 161 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 161 9>, <_clks 161 1>;
+   clock-names = "ref", "lpm";
+   assigned-clocks = <_clks 161 9>; /* USB2_REFCLK */
+   assigned-clock-parents = <_clks 161 10>; /* HF0SC0 */
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   usb0: usb@f40{
+   compatible = "cdns,usb3";
+   reg = <0x00 0xf40 0x00 0x1>,
+ <0x00 0xf41 0x00 0x1>,
+ <0x00 0xf42 0x00 0x1>;
+   reg-names = "otg",
+   "xhci",
+   "dev";
+   interrupts = , /* 
irq.0 */
+, /* 
irq.6 */
+; /* 
otgirq */
+   interrupt-names = "host",
+ "peripheral",
+ "otg";
+   maximum-speed = "super-speed";
+   dr_mode = "otg";
+   };
+   };
 };
-- 
2.17.1



[PATCH v2 0/2] AM64: Add USB support

2021-03-10 Thread Aswath Govindraju
The following series of patches, add USB support for AM642 evm.

USB test logs,
https://pastebin.ubuntu.com/p/Qrbb7SGv8N/

Changes since v1:
- Rebased the patches on top of ti-k3-dts-next
- Added test logs

Aswath Govindraju (2):
  arm64: dts: ti: k3-am64-main: Add DT node for USB subsystem
  arm64: dts: ti: k3-am642-evm: Add USB support

 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 30 
 arch/arm64/boot/dts/ti/k3-am642-evm.dts  | 18 ++
 2 files changed, 48 insertions(+)

-- 
2.17.1



Re: [PATCH 0/2] AM64: Add USB support

2021-03-09 Thread Aswath Govindraju
Hi Kishon,

On 10/03/21 12:33 pm, Kishon Vijay Abraham I wrote:
> +Vinod
> 
> Hi Aswath,
> 
> On 10/03/21 12:27 pm, Aswath Govindraju wrote:
>> Hi Nishanth,
>>
>> On 01/03/21 8:52 pm, Nishanth Menon wrote:
>>> On 11:21-20210301, Aswath Govindraju wrote:
>>>> The following series of patches, add USB support for AM64.
>>>>
>>>> This series of patches depends on,
>>>> https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=439039
>>>>
>>>> Aswath Govindraju (2):
>>>>   arm64: dts: ti: k3-am64-main: Add DT node for USB subsystem
>>>>   arm64: dts: ti: k3-am642-evm: Add USB support
>>>>
>>>>  arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 30 
>>>>  arch/arm64/boot/dts/ti/k3-am642-evm.dts  | 18 ++
>>>>  2 files changed, 48 insertions(+)
>>>
>>> Please update the series to include SK as well.
>>>
>>
>> I was planning on posting patches that add support for USB in SK later
>> because of phy dependencies.
> 
> The dependency is only on [1] right? I've got all the required ACKs so
> it should be okay to include it in this series. (That patch will be
> required only when PCIe DT is merged for me.)
> 
> Nishant, would you be okay to merge [1] along with other patches from
> Aswath? There is no dependency as such on my other PHY patches, so don't
> think there is a need for a stable tag here.
> 
> 
> [1] ->
> https://lore.kernel.org/linux-devicetree/20210222112314.10772-4-kis...@ti.com/
>>

There is also a dependency on,

https://lore.kernel.org/linux-devicetree/20210222112314.10772-2-kis...@ti.com/

Thanks,
Aswath


Re: [PATCH 0/2] AM64: Add USB support

2021-03-09 Thread Aswath Govindraju
Hi Nishanth,

On 01/03/21 8:52 pm, Nishanth Menon wrote:
> On 11:21-20210301, Aswath Govindraju wrote:
>> The following series of patches, add USB support for AM64.
>>
>> This series of patches depends on,
>> https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=439039
>>
>> Aswath Govindraju (2):
>>   arm64: dts: ti: k3-am64-main: Add DT node for USB subsystem
>>   arm64: dts: ti: k3-am642-evm: Add USB support
>>
>>  arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 30 
>>  arch/arm64/boot/dts/ti/k3-am642-evm.dts  | 18 ++
>>  2 files changed, 48 insertions(+)
> 
> Please update the series to include SK as well.
> 

I was planning on posting patches that add support for USB in SK later
because of phy dependencies.

Thanks,
Aswath


[PATCH v2] arm64: dts: ti: k3-am642-evm: Add support for SPI EEPROM

2021-03-09 Thread Aswath Govindraju
Add pinmux details and device tree node for the EEPROM attached to SPI0
module in main domain.

Signed-off-by: Aswath Govindraju 
Reviewed-by: Vignesh Raghavendra 
---

Link to test log,
https://pastebin.ubuntu.com/p/jDgvyhF9BQ/

Changes since v1:
- Removed the dependency on USB support patches
- Picked up reviewed-by
- Added test logs for SPI EEPROM

 arch/arm64/boot/dts/ti/k3-am642-evm.dts | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am642-evm.dts 
b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
index 1f1787750fef..f5a8c5c4c8c3 100644
--- a/arch/arm64/boot/dts/ti/k3-am642-evm.dts
+++ b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
@@ -127,6 +127,15 @@
>;
};
 
+   main_spi0_pins_default: main-spi0-pins-default {
+   pinctrl-single,pins = <
+   AM64X_IOPAD(0x0210, PIN_INPUT, 0) /* (D13) SPI0_CLK */
+   AM64X_IOPAD(0x0208, PIN_OUTPUT, 0) /* (D12) SPI0_CS0 */
+   AM64X_IOPAD(0x0214, PIN_OUTPUT, 0) /* (A13) SPI0_D0 */
+   AM64X_IOPAD(0x0218, PIN_INPUT, 0) /* (A14) SPI0_D1 */
+   >;
+   };
+
main_i2c1_pins_default: main-i2c1-pins-default {
pinctrl-single,pins = <
AM64X_IOPAD(0x0268, PIN_INPUT_PULLUP, 0) /* (C18) 
I2C1_SCL */
@@ -227,6 +236,19 @@
status = "disabled";
 };
 
+_spi0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <_spi0_pins_default>;
+   ti,pindir-d0-out-d1-in = <1>;
+   eeprom@0 {
+   compatible = "microchip,93lc46b";
+   reg = <0>;
+   spi-max-frequency = <100>;
+   spi-cs-high;
+   data-size = <16>;
+   };
+};
+
  {
/* emmc */
bus-width = <8>;
-- 
2.17.1



Re: [PATCH v2 0/2] AM64: Add support for GPIO

2021-03-09 Thread Aswath Govindraju
Hi Nishanth,

On 09/03/21 8:13 pm, Nishanth Menon wrote:
> On 16:59-20210304, Aswath Govindraju wrote:
>> The following series of patches adds support for gpio on AM642 evm/sk.
>>
>> Changes since v1:
>> - Added DT for gpio subsystem present in MCU domain
>> - reserved the mcu gpio for firmware usage
>>
>> This series of patches depend on,
>> https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=439039
>> https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=439153
>>
>>
>> Aswath Govindraju (2):
>>   arm64: dts: ti: k3-am64: Add GPIO DT nodes
>>   arm64: dts: ti: k3-am642: reserve gpio in mcu domain for firmware
>> usage
>>
>>  arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 45 
>>  arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi  | 27 ++
>>  arch/arm64/boot/dts/ti/k3-am642-evm.dts  |  5 +++
>>  arch/arm64/boot/dts/ti/k3-am642-sk.dts   |  5 +++
>>  4 files changed, 82 insertions(+)
>>
>> -- 
>> 2.17.1
>>
> 
> 
> Based on your offline comment:
> -
> 
> On going through the bootlogs before posting for I found the following
> errors,
> 
> [1.091117] davinci_gpio 601000.gpio: IRQ index 2 not found
> [1.101522] davinci_gpio 601000.gpio: error -ENXIO: IRQ not populated
> 
> Some issues in allocating interrupts in case of main_gpio1. I
> accumulated the gpio with interrupt numbers. I'll try to debug the
> reason behind it and update you with its status. (bootlogs of ti-sdk,
> also have this error).
> 
> -
> 
> I am going to drop this off my queue, please update if the fixup is some
> system configuration error or repost with fix.
> 

This is expected to be a fixup in the system configuration and not a bug
in the patch series. So, can you please have these patches in your queue
? I'll soon post the test results indicating the functioning of GPIOs.

Thanks,
Aswath


Re: [PATCH] arm64: dts: ti: k3-am642-evm: Add support for SPI EEPROM

2021-03-09 Thread Aswath Govindraju
Hi Nishanth,

On 09/03/21 8:24 pm, Nishanth Menon wrote:
> On 20:18-20210309, Vignesh Raghavendra wrote:
>>
>>
>> On 3/1/21 11:35 AM, Aswath Govindraju wrote:
>>> Add pinmux details and device tree node for the EEPROM attached to SPI0
>>> module in main domain.
>>>
>>> Signed-off-by: Aswath Govindraju 
>>> ---
>>
>> Reviewed-by: Vignesh Raghavendra 
>>
>> Regards
>> Vignesh
>>
>>>
>>> This patch depends on,
>>> https://patchwork.kernel.org/project/linux-arm-kernel/patch/20210301055109.17626-3-a-govindr...@ti.com/
> 
> 
> Can you drop this dependency and rebase on top of my -next branch or
> linux-next ? I am not able to apply the patch directly and would like to
> avoid hand modifying the patch.
> 

ok, I'll post a respin after dropping this dependency and picking up the
reviewed by.

Thanks,
Aswath

>>>
>>>  arch/arm64/boot/dts/ti/k3-am642-evm.dts | 22 ++
>>>  1 file changed, 22 insertions(+)
>>>
>>> diff --git a/arch/arm64/boot/dts/ti/k3-am642-evm.dts 
>>> b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
>>> index bfd849a29655..bc5bd7f896ab 100644
>>> --- a/arch/arm64/boot/dts/ti/k3-am642-evm.dts
>>> +++ b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
>>> @@ -139,6 +139,15 @@
>>> AM64X_IOPAD(0x02a8, PIN_OUTPUT, 0) /* (E19) 
>>> USB0_DRVVBUS */
>>> >;
>>> };
>>> +
>>> +   main_spi0_pins_default: main-spi0-pins-default {
>>> +   pinctrl-single,pins = <
>>> +   AM64X_IOPAD(0x0210, PIN_INPUT, 0) /* (D13) SPI0_CLK */
>>> +   AM64X_IOPAD(0x0208, PIN_OUTPUT, 0) /* (D12) SPI0_CS0 */
>>> +   AM64X_IOPAD(0x0214, PIN_OUTPUT, 0) /* (A13) SPI0_D0 */
>>> +   AM64X_IOPAD(0x0218, PIN_INPUT, 0) /* (A14) SPI0_D1 */
>>> +   >;
>>> +   };
>>>  };
>>>  
>>>  _uart0 {
>>> @@ -245,6 +254,19 @@
>>> pinctrl-0 = <_usb0_pins_default>;
>>>  };
>>>  
>>> +_spi0 {
>>> +   pinctrl-names = "default";
>>> +   pinctrl-0 = <_spi0_pins_default>;
>>> +   ti,pindir-d0-out-d1-in = <1>;
>>> +   eeprom@0 {
>>> +   compatible = "microchip,93lc46b";
>>> +   reg = <0>;
>>> +   spi-max-frequency = <100>;
>>> +   spi-cs-high;
>>> +   data-size = <16>;
>>> +   };
>>> +};
>>> +
>>>   {
>>> /* emmc */
>>> bus-width = <8>;
>>>
> 



Re: [PATCH] usb: cdns3: Coherent memory allocation optimization

2021-03-09 Thread Aswath Govindraju
Hi Peter,

On 09/03/21 11:09 am, Sanket Parmar wrote:
> Hi Peter,
> 
>> On 21-03-05 17:01:11, Sanket Parmar wrote:
>>> Allocation of DMA coherent memory in atomic context using
>>> dma_alloc_coherent() might fail on some platform. To fix it,
>>> Replaced dma_alloc_coherent() with dma_pool API to allocate a
>>> smaller chunk of DMA coherent memory for TRB rings.
>>>
>>> Also in cdns3_prepare_aligned_request_buf(), replaced
>>> dma_alloc_coherent() with kmalloc and dma_map API to allocate
>>> aligned request buffer of dynamic length.
>>>
>>
>> You do two changes in one commit, would you please split this one as
>> two patches?
>>
>>> Fixes: commit 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
>>
>> "commit" is not needed
>>
>>> Reported by: Aswath Govindraju 
>>
>> Reported-by:
>>
> I have split the change into two patches.
> New patch series has been posted already.
>  
>>> Signed-off-by: Sanket Parmar 
>>> ---
>>>  drivers/usb/cdns3/cdns3-gadget.c |  115 ++
>> ---
>>>  drivers/usb/cdns3/cdns3-gadget.h |3 +
>>>  2 files changed, 71 insertions(+), 47 deletions(-)
>>>
>>> diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-
>> gadget.c
>>> index 582bfec..5fd6993 100644
>>> --- a/drivers/usb/cdns3/cdns3-gadget.c
>>> +++ b/drivers/usb/cdns3/cdns3-gadget.c
>>> @@ -59,6 +59,7 @@
>>>  #include 
>>>  #include 
>>>  #include 
>>> +#include 
>>>  #include 
>>>
>>>  #include "core.h"
>>> @@ -190,29 +191,13 @@ dma_addr_t cdns3_trb_virt_to_dma(struct
>> cdns3_endpoint *priv_ep,
>>> return priv_ep->trb_pool_dma + offset;
>>>  }
>>>
>>> -static int cdns3_ring_size(struct cdns3_endpoint *priv_ep)
>>> -{
>>> -   switch (priv_ep->type) {
>>> -   case USB_ENDPOINT_XFER_ISOC:
>>> -   return TRB_ISO_RING_SIZE;
>>> -   case USB_ENDPOINT_XFER_CONTROL:
>>> -   return TRB_CTRL_RING_SIZE;
>>> -   default:
>>> -   if (priv_ep->use_streams)
>>> -   return TRB_STREAM_RING_SIZE;
>>> -   else
>>> -   return TRB_RING_SIZE;
>>> -   }
>>> -}
>>> -
>>>  static void cdns3_free_trb_pool(struct cdns3_endpoint *priv_ep)
>>>  {
>>> struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
>>>
>>> if (priv_ep->trb_pool) {
>>> -   dma_free_coherent(priv_dev->sysdev,
>>> - cdns3_ring_size(priv_ep),
>>> - priv_ep->trb_pool, priv_ep->trb_pool_dma);
>>> +   dma_pool_free(priv_dev->eps_dma_pool,
>>> +   priv_ep->trb_pool, priv_ep->trb_pool_dma);
>>> priv_ep->trb_pool = NULL;
>>> }
>>>  }
>>> @@ -226,7 +211,7 @@ static void cdns3_free_trb_pool(struct
>> cdns3_endpoint *priv_ep)
>>>  int cdns3_allocate_trb_pool(struct cdns3_endpoint *priv_ep)
>>>  {
>>> struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
>>> -   int ring_size = cdns3_ring_size(priv_ep);
>>> +   int ring_size = TRB_RING_SIZE;
>>
>> You will use the same size for TRB ring region for control/bulk/isoc
>> endpoint.
>>
> As single DMA pool is used to allocate the ring buffer, different TRB ring
> size is not possible for different EP. Hence, TRB_RING_SIZE(600 * 12 B) which 
> fits
> for all type of EPs is used.
> 
>>> int num_trbs = ring_size / TRB_SIZE;
>>> struct cdns3_trb *link_trb;
>>>
>>> @@ -234,10 +219,10 @@ int cdns3_allocate_trb_pool(struct
>> cdns3_endpoint *priv_ep)
>>> cdns3_free_trb_pool(priv_ep);
>>>
>>> if (!priv_ep->trb_pool) {
>>> -   priv_ep->trb_pool = dma_alloc_coherent(priv_dev->sysdev,
>>> -  ring_size,
>>> -  _ep->trb_pool_dma,
>>> -  GFP_DMA32 |
>> GFP_ATOMIC);
>>> +   priv_ep->trb_pool = dma_pool_alloc(priv_dev-
>>> eps_dma_pool,
>>> +   GFP_DMA32 | GFP_ATOMIC,
>>> +   _ep->trb_pool_dma);
>>

[PATCH v2] arm64: dts: ti: k3-j721e-main: Update the speed modes supported and their itap delay values for MMCSD subsystems

2021-03-04 Thread Aswath Govindraju
According to latest errata of J721e [1], HS400 mode is not supported
in MMCSD0 subsystem (i2024) and SDR104 mode is not supported in MMCSD1/2
subsystems (i2090). Therefore, replace mmc-hs400-1_8v with mmc-hs200-1_8v
in MMCSD0 subsystem and add a sdhci mask to disable SDR104 speed mode.

Also, update the itap delay values for all the MMCSD subsystems according
the latest J721e data sheet[2]

[1] - https://www.ti.com/lit/er/sprz455/sprz455.pdf
[2] - https://www.ti.com/lit/ds/symlink/tda4vm.pdf

Fixes: cd48ce86a4d0 ("arm64: dts: ti: k3-j721e-common-proc-board: Add support 
for SD card UHS modes")
Signed-off-by: Aswath Govindraju 
---

Changes since v1:
- Corrected the fixes tag to latest commit that makes changes to the
  sdhci DT nodes.

 arch/arm64/boot/dts/ti/k3-j721e-main.dtsi | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi
index 8c84dafb7125..f1e7da3dfa27 100644
--- a/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi
@@ -1042,13 +1042,16 @@
assigned-clocks = <_clks 91 1>;
assigned-clock-parents = <_clks 91 2>;
bus-width = <8>;
-   mmc-hs400-1_8v;
+   mmc-hs200-1_8v;
mmc-ddr-1_8v;
ti,otap-del-sel-legacy = <0xf>;
ti,otap-del-sel-mmc-hs = <0xf>;
ti,otap-del-sel-ddr52 = <0x5>;
ti,otap-del-sel-hs200 = <0x6>;
ti,otap-del-sel-hs400 = <0x0>;
+   ti,itap-del-sel-legacy = <0x10>;
+   ti,itap-del-sel-mmc-hs = <0xa>;
+   ti,itap-del-sel-ddr52 = <0x3>;
ti,trm-icp = <0x8>;
ti,strobe-sel = <0x77>;
dma-coherent;
@@ -1069,9 +1072,15 @@
ti,otap-del-sel-sdr25 = <0xf>;
ti,otap-del-sel-sdr50 = <0xc>;
ti,otap-del-sel-ddr50 = <0xc>;
+   ti,itap-del-sel-legacy = <0x0>;
+   ti,itap-del-sel-sd-hs = <0x0>;
+   ti,itap-del-sel-sdr12 = <0x0>;
+   ti,itap-del-sel-sdr25 = <0x0>;
+   ti,itap-del-sel-ddr50 = <0x2>;
ti,trm-icp = <0x8>;
ti,clkbuf-sel = <0x7>;
dma-coherent;
+   sdhci-caps-mask = <0x2 0x0>;
};
 
main_sdhci2: mmc@4f98000 {
@@ -1089,9 +1098,15 @@
ti,otap-del-sel-sdr25 = <0xf>;
ti,otap-del-sel-sdr50 = <0xc>;
ti,otap-del-sel-ddr50 = <0xc>;
+   ti,itap-del-sel-legacy = <0x0>;
+   ti,itap-del-sel-sd-hs = <0x0>;
+   ti,itap-del-sel-sdr12 = <0x0>;
+   ti,itap-del-sel-sdr25 = <0x0>;
+   ti,itap-del-sel-ddr50 = <0x2>;
ti,trm-icp = <0x8>;
ti,clkbuf-sel = <0x7>;
dma-coherent;
+   sdhci-caps-mask = <0x2 0x0>;
};
 
usbss0: cdns-usb@4104000 {
-- 
2.17.1



Re: [PATCH] arm64: dts: ti: k3-j721e-main: Update the speed modes supported and their itap delay values for MMCSD subsystems

2021-03-04 Thread Aswath Govindraju
Hi Nishanth,

On 05/03/21 10:44 am, Nishanth Menon wrote:
> On 10:59-20210301, Kishon Vijay Abraham I wrote:
>> On 25/02/21 6:57 pm, Aswath Govindraju wrote:
>>> According to latest errata of J721e [1], HS400 mode is not supported
>>> in MMCSD0 subsystem (i2024) and SDR104 mode is not supported in MMCSD1/2
>>> subsystems (i2090). Therefore, replace mmc-hs400-1_8v with mmc-hs200-1_8v
>>> in MMCSD0 subsystem and add a sdhci mask to disable SDR104 speed mode.
>>>
>>> Also, update the itap delay values for all the MMCSD subsystems according
>>> the latest J721e data sheet[2]
>>>
>>> [1] - https://www.ti.com/lit/er/sprz455/sprz455.pdf
>>> [2] - https://www.ti.com/lit/ds/symlink/tda4vm.pdf
>>>
>>> Fixes: e6dc10f200da ("arm64: dts: ti: j721e-main: Add SDHCI nodes")
>>> Signed-off-by: Aswath Govindraju 
>>
>> Reviewed-by: Kishon Vijay Abraham I 
> 
> 
> In some offline testing, I realized that the patch wont apply cleanly to 
> e6dc10f200da
> 
> cd48ce86a4d0c1ffec86aa46a26da993c9af5f53 might be a better candidate for
> this - I will drop the patch from my queue in the morning, could you
> update the patch with a new rev with appropriate Fixes?
> 

Sorry, I'll send a respin(v2) of this patch after correcting the fixes
tag to,
Fixes: cd48ce86a4d0 ("arm64: dts: ti: k3-j721e-common-proc-board: Add
support for SD card UHS modes")

Thanks,
Aswath


[PATCH v2 0/2] AM64: Add support for GPIO

2021-03-04 Thread Aswath Govindraju
The following series of patches adds support for gpio on AM642 evm/sk.

Changes since v1:
- Added DT for gpio subsystem present in MCU domain
- reserved the mcu gpio for firmware usage

This series of patches depend on,
https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=439039
https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=439153


Aswath Govindraju (2):
  arm64: dts: ti: k3-am64: Add GPIO DT nodes
  arm64: dts: ti: k3-am642: reserve gpio in mcu domain for firmware
usage

 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 45 
 arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi  | 27 ++
 arch/arm64/boot/dts/ti/k3-am642-evm.dts  |  5 +++
 arch/arm64/boot/dts/ti/k3-am642-sk.dts   |  5 +++
 4 files changed, 82 insertions(+)

-- 
2.17.1



[PATCH v2 2/2] arm64: dts: ti: k3-am642: reserve gpio in mcu domain for firmware usage

2021-03-04 Thread Aswath Govindraju
The gpio0 subsystem present in MCU domain might be used by firmware and is
not pinned out in evm/sk. Therefore, reserve it for MCU firmware.

Signed-off-by: Aswath Govindraju 
---
 arch/arm64/boot/dts/ti/k3-am642-evm.dts | 5 +
 arch/arm64/boot/dts/ti/k3-am642-sk.dts  | 5 +
 2 files changed, 10 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am642-evm.dts 
b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
index 962ef807e286..982b043c5100 100644
--- a/arch/arm64/boot/dts/ti/k3-am642-evm.dts
+++ b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
@@ -279,6 +279,11 @@
};
 };
 
+/* mcu_gpio0 is reserved for mcu firmware usage */
+_gpio0 {
+   status = "reserved";
+};
+
 _i2c0 {
status = "disabled";
 };
diff --git a/arch/arm64/boot/dts/ti/k3-am642-sk.dts 
b/arch/arm64/boot/dts/ti/k3-am642-sk.dts
index 397ed3b2e121..7ba1d6da4d9d 100644
--- a/arch/arm64/boot/dts/ti/k3-am642-sk.dts
+++ b/arch/arm64/boot/dts/ti/k3-am642-sk.dts
@@ -204,6 +204,11 @@
status = "disabled";
 };
 
+/* mcu_gpio0 is reserved for mcu firmware usage */
+_gpio0 {
+   status = "reserved";
+};
+
  {
/* SD/MMC */
vmmc-supply = <_mmc1>;
-- 
2.17.1



[PATCH v2 1/2] arm64: dts: ti: k3-am64: Add GPIO DT nodes

2021-03-04 Thread Aswath Govindraju
Add device tree nodes for GPIO modules and interrupt controller in main
and mcu domains.

Signed-off-by: Aswath Govindraju 
---
 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 45 
 arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi  | 27 ++
 2 files changed, 72 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
index 0cf727e3d1e2..f580d5357051 100644
--- a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
@@ -373,6 +373,51 @@
clocks = <_clks 145 0>;
};
 
+   main_gpio_intr: interrupt-controller0 {
+   compatible = "ti,sci-intr";
+   ti,intr-trigger-type = <1>;
+   interrupt-controller;
+   interrupt-parent = <>;
+   #interrupt-cells = <1>;
+   ti,sci = <>;
+   ti,sci-dev-id = <3>;
+   ti,interrupt-ranges = <0 32 16>;
+   };
+
+   main_gpio0: gpio@60 {
+   compatible = "ti,am64-gpio", "ti,keystone-gpio";
+   reg = <0x0 0x0060 0x0 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <190>, <191>, <192>,
+<193>, <194>, <195>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   ti,ngpio = <87>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 77 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 77 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio1: gpio@601000 {
+   compatible = "ti,am64-gpio", "ti,keystone-gpio";
+   reg = <0x0 0x00601000 0x0 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <180>, <181>, <182>,
+<183>, <184>, <185>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   ti,ngpio = <88>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 78 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 78 0>;
+   clock-names = "gpio";
+   };
+
sdhci0: mmc@fa1 {
compatible = "ti,am64-sdhci-8bit";
reg = <0x00 0xfa1 0x00 0x260>, <0x00 0xfa18000 0x00 0x134>;
diff --git a/arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi 
b/arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi
index 1d2be485a669..99e94dee1bd4 100644
--- a/arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am64-mcu.dtsi
@@ -73,4 +73,31 @@
power-domains = <_pds 148 TI_SCI_PD_EXCLUSIVE>;
clocks = <_clks 148 0>;
};
+
+   mcu_gpio_intr: interrupt-controller1 {
+   compatible = "ti,sci-intr";
+   ti,intr-trigger-type = <1>;
+   interrupt-controller;
+   interrupt-parent = <>;
+   #interrupt-cells = <1>;
+   ti,sci = <>;
+   ti,sci-dev-id = <5>;
+   ti,interrupt-ranges = <0 104 4>;
+   };
+
+   mcu_gpio0: gpio@4201000 {
+   compatible = "ti,am64-gpio", "keystone-gpio";
+   reg = <0x0 0x4201000 0x0 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <30>, <31>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   ti,ngpio = <23>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 79 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 79 0>;
+   clock-names = "gpio";
+   };
 };
-- 
2.17.1



[PATCH] arm64: dts: ti: k3-am64-main: Add GPIO DT nodes

2021-02-28 Thread Aswath Govindraju
Add device tree nodes for GPIO modules and interrupt controller in main
domain.

Signed-off-by: Aswath Govindraju 
---

This patch depends on,
https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=439039


 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 45 
 1 file changed, 45 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
index a36ebddf3a4c..8b4d76d83342 100644
--- a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
@@ -367,6 +367,51 @@
clocks = <_clks 145 0>;
};
 
+   main_gpio_intr: interrupt-controller0 {
+   compatible = "ti,sci-intr";
+   ti,intr-trigger-type = <1>;
+   interrupt-controller;
+   interrupt-parent = <>;
+   #interrupt-cells = <1>;
+   ti,sci = <>;
+   ti,sci-dev-id = <3>;
+   ti,interrupt-ranges = <0 32 16>;
+   };
+
+   main_gpio0: gpio@60 {
+   compatible = "ti,am64-gpio", "ti,keystone-gpio";
+   reg = <0x0 0x0060 0x0 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <190>, <191>, <192>,
+<193>, <194>, <195>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   ti,ngpio = <87>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 77 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 77 0>;
+   clock-names = "gpio";
+   };
+
+   main_gpio1: gpio@601000 {
+   compatible = "ti,am64-gpio", "ti,keystone-gpio";
+   reg = <0x0 0x00601000 0x0 0x100>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   interrupt-parent = <_gpio_intr>;
+   interrupts = <180>, <181>, <182>,
+<183>, <184>, <185>;
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   ti,ngpio = <88>;
+   ti,davinci-gpio-unbanked = <0>;
+   power-domains = <_pds 78 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 78 0>;
+   clock-names = "gpio";
+   };
+
sdhci0: mmc@fa1 {
compatible = "ti,am64-sdhci-8bit";
reg = <0x00 0xfa1 0x00 0x260>, <0x00 0xfa18000 0x00 0x134>;
-- 
2.17.1



[PATCH] arm64: dts: ti: k3-am642-evm: Add support for SPI EEPROM

2021-02-28 Thread Aswath Govindraju
Add pinmux details and device tree node for the EEPROM attached to SPI0
module in main domain.

Signed-off-by: Aswath Govindraju 
---

This patch depends on,
https://patchwork.kernel.org/project/linux-arm-kernel/patch/20210301055109.17626-3-a-govindr...@ti.com/

 arch/arm64/boot/dts/ti/k3-am642-evm.dts | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am642-evm.dts 
b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
index bfd849a29655..bc5bd7f896ab 100644
--- a/arch/arm64/boot/dts/ti/k3-am642-evm.dts
+++ b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
@@ -139,6 +139,15 @@
AM64X_IOPAD(0x02a8, PIN_OUTPUT, 0) /* (E19) 
USB0_DRVVBUS */
>;
};
+
+   main_spi0_pins_default: main-spi0-pins-default {
+   pinctrl-single,pins = <
+   AM64X_IOPAD(0x0210, PIN_INPUT, 0) /* (D13) SPI0_CLK */
+   AM64X_IOPAD(0x0208, PIN_OUTPUT, 0) /* (D12) SPI0_CS0 */
+   AM64X_IOPAD(0x0214, PIN_OUTPUT, 0) /* (A13) SPI0_D0 */
+   AM64X_IOPAD(0x0218, PIN_INPUT, 0) /* (A14) SPI0_D1 */
+   >;
+   };
 };
 
 _uart0 {
@@ -245,6 +254,19 @@
pinctrl-0 = <_usb0_pins_default>;
 };
 
+_spi0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <_spi0_pins_default>;
+   ti,pindir-d0-out-d1-in = <1>;
+   eeprom@0 {
+   compatible = "microchip,93lc46b";
+   reg = <0>;
+   spi-max-frequency = <100>;
+   spi-cs-high;
+   data-size = <16>;
+   };
+};
+
  {
/* emmc */
bus-width = <8>;
-- 
2.17.1



[PATCH 2/2] arm64: dts: ti: k3-am642-evm: Add USB support

2021-02-28 Thread Aswath Govindraju
AM64 EVM board has a micro USB 2.0 AB connector and the USB0_VBUS is
connected with a resistor divider in between. USB0_DRVVBUS pin is muxed
between USB0_DRVVBUS and GPIO1_79 signals.

Add the corresponding properties and set the pinmux mode for USB subsystem
in the evm dts file.

Signed-off-by: Aswath Govindraju 
Acked-by: Roger Quadros 
---
 arch/arm64/boot/dts/ti/k3-am642-evm.dts | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am642-evm.dts 
b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
index 1f1787750fef..bfd849a29655 100644
--- a/arch/arm64/boot/dts/ti/k3-am642-evm.dts
+++ b/arch/arm64/boot/dts/ti/k3-am642-evm.dts
@@ -133,6 +133,12 @@
AM64X_IOPAD(0x026c, PIN_INPUT_PULLUP, 0) /* (B19) 
I2C1_SDA */
>;
};
+
+   main_usb0_pins_default: main-usb0-pins-default {
+   pinctrl-single,pins = <
+   AM64X_IOPAD(0x02a8, PIN_OUTPUT, 0) /* (E19) 
USB0_DRVVBUS */
+   >;
+   };
 };
 
 _uart0 {
@@ -227,6 +233,18 @@
status = "disabled";
 };
 
+ {
+   ti,vbus-divider;
+   ti,usb2-only;
+};
+
+ {
+   dr_mode = "otg";
+   maximum-speed = "high-speed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_usb0_pins_default>;
+};
+
  {
/* emmc */
bus-width = <8>;
-- 
2.17.1



[PATCH 0/2] AM64: Add USB support

2021-02-28 Thread Aswath Govindraju
The following series of patches, add USB support for AM64.

This series of patches depends on,
https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=439039

Aswath Govindraju (2):
  arm64: dts: ti: k3-am64-main: Add DT node for USB subsystem
  arm64: dts: ti: k3-am642-evm: Add USB support

 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 30 
 arch/arm64/boot/dts/ti/k3-am642-evm.dts  | 18 ++
 2 files changed, 48 insertions(+)

-- 
2.17.1



[PATCH 1/2] arm64: dts: ti: k3-am64-main: Add DT node for USB subsystem

2021-02-28 Thread Aswath Govindraju
Add DT node for the single USB subsystem in main dtsi file.

Signed-off-by: Aswath Govindraju 
Acked-by: Roger Quadros 
---
 arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 30 
 1 file changed, 30 insertions(+)

diff --git a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
index 5f85950daef7..a36ebddf3a4c 100644
--- a/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am64-main.dtsi
@@ -402,4 +402,34 @@
ti,otap-del-sel-ddr50 = <0x9>;
ti,clkbuf-sel = <0x7>;
};
+
+   usbss0: cdns-usb@f90{
+   compatible = "ti,am64-usb", "ti,j721e-usb";
+   reg = <0x00 0xf90 0x00 0x100>;
+   power-domains = <_pds 161 TI_SCI_PD_EXCLUSIVE>;
+   clocks = <_clks 161 9>, <_clks 161 1>;
+   clock-names = "ref", "lpm";
+   assigned-clocks = <_clks 161 9>; /* USB2_REFCLK */
+   assigned-clock-parents = <_clks 161 10>; /* HF0SC0 */
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   usb0: usb@f40{
+   compatible = "cdns,usb3";
+   reg = <0x00 0xf40 0x00 0x1>,
+ <0x00 0xf41 0x00 0x1>,
+ <0x00 0xf42 0x00 0x1>;
+   reg-names = "otg",
+   "xhci",
+   "dev";
+   interrupts = , /* 
irq.0 */
+, /* 
irq.6 */
+; /* 
otgirq */
+   interrupt-names = "host",
+ "peripheral",
+ "otg";
+   maximum-speed = "super-speed";
+   dr_mode = "otg";
+   };
+   };
 };
-- 
2.17.1



[PATCH] arm64: dts: ti: k3-j721e-main: Update the speed modes supported and their itap delay values for MMCSD subsystems

2021-02-25 Thread Aswath Govindraju
According to latest errata of J721e [1], HS400 mode is not supported
in MMCSD0 subsystem (i2024) and SDR104 mode is not supported in MMCSD1/2
subsystems (i2090). Therefore, replace mmc-hs400-1_8v with mmc-hs200-1_8v
in MMCSD0 subsystem and add a sdhci mask to disable SDR104 speed mode.

Also, update the itap delay values for all the MMCSD subsystems according
the latest J721e data sheet[2]

[1] - https://www.ti.com/lit/er/sprz455/sprz455.pdf
[2] - https://www.ti.com/lit/ds/symlink/tda4vm.pdf

Fixes: e6dc10f200da ("arm64: dts: ti: j721e-main: Add SDHCI nodes")
Signed-off-by: Aswath Govindraju 
---
 arch/arm64/boot/dts/ti/k3-j721e-main.dtsi | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi 
b/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi
index 8c84dafb7125..f1e7da3dfa27 100644
--- a/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j721e-main.dtsi
@@ -1042,13 +1042,16 @@
assigned-clocks = <_clks 91 1>;
assigned-clock-parents = <_clks 91 2>;
bus-width = <8>;
-   mmc-hs400-1_8v;
+   mmc-hs200-1_8v;
mmc-ddr-1_8v;
ti,otap-del-sel-legacy = <0xf>;
ti,otap-del-sel-mmc-hs = <0xf>;
ti,otap-del-sel-ddr52 = <0x5>;
ti,otap-del-sel-hs200 = <0x6>;
ti,otap-del-sel-hs400 = <0x0>;
+   ti,itap-del-sel-legacy = <0x10>;
+   ti,itap-del-sel-mmc-hs = <0xa>;
+   ti,itap-del-sel-ddr52 = <0x3>;
ti,trm-icp = <0x8>;
ti,strobe-sel = <0x77>;
dma-coherent;
@@ -1069,9 +1072,15 @@
ti,otap-del-sel-sdr25 = <0xf>;
ti,otap-del-sel-sdr50 = <0xc>;
ti,otap-del-sel-ddr50 = <0xc>;
+   ti,itap-del-sel-legacy = <0x0>;
+   ti,itap-del-sel-sd-hs = <0x0>;
+   ti,itap-del-sel-sdr12 = <0x0>;
+   ti,itap-del-sel-sdr25 = <0x0>;
+   ti,itap-del-sel-ddr50 = <0x2>;
ti,trm-icp = <0x8>;
ti,clkbuf-sel = <0x7>;
dma-coherent;
+   sdhci-caps-mask = <0x2 0x0>;
};
 
main_sdhci2: mmc@4f98000 {
@@ -1089,9 +1098,15 @@
ti,otap-del-sel-sdr25 = <0xf>;
ti,otap-del-sel-sdr50 = <0xc>;
ti,otap-del-sel-ddr50 = <0xc>;
+   ti,itap-del-sel-legacy = <0x0>;
+   ti,itap-del-sel-sd-hs = <0x0>;
+   ti,itap-del-sel-sdr12 = <0x0>;
+   ti,itap-del-sel-sdr25 = <0x0>;
+   ti,itap-del-sel-ddr50 = <0x2>;
ti,trm-icp = <0x8>;
ti,clkbuf-sel = <0x7>;
dma-coherent;
+   sdhci-caps-mask = <0x2 0x0>;
};
 
usbss0: cdns-usb@4104000 {
-- 
2.17.1



  1   2   >