airoha: en7581: clk cleanup + USB support
Subsystems (6)
v2 cover airoha: en7581: clk cleanup + USB support
This series implement all the changes required to correctly handle USB support for the Airoha EN7581 SoC.
The first few patch are cleanup for the clock driver and the introduction of the SCU SSR SoC driver.
The SoC always support USB 2.0 but for USB 3.0 it needs additional configuration for the Serdes port. Such port can be either configured for USB usage or for PCIe lines or HSGMII and these are configured in the SCU space.
The xHCI USB is based on the Mediatek implementation but the PHY handling although conceptually similar, is indded different compared to Mediatek due to SSR checks and different port power up.
The SSR driver expose an API to poll the current status of the Serdes port and the USB PHY driver validates it. Refer to the specific commit for additional info.
Consider that there is currently an inconsistency as AN7581 and EN7581 refer to the same thing. This is due to the fact that the SoC born under EcoNet but then was acquired by Airoha.
Changes v2:
- Drop changes for simple-mfd
- Rework PHY node structure to single node
- Drop port-id property in favor of serdes-port and usb2-monitor-clock-sel
- Make the SSR driver probe from the clock driver
Christian Marangi (11):
clk: en7523: convert driver to regmap API
clk: en7523: generalize register clocks function
dt-bindings: clock: en7523: add Documentation for Airoha AN7581 SCU
SSR
soc: airoha: add support for configuring SCU SSR Serdes port
clk: en7523: define and register SoC SCU SSR driver for EN7581
soc: airoha: scu-ssr: expose API to read current Serdes Port mode
dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY
phy: move Airoha PCIe PHY driver to dedicated directory
phy: airoha: Add support for Airoha AN7581 USB PHY
usb: host: add ARCH_AIROHA in XHCI MTK dependency
arm64: dts: airoha: en7581: add USB nodes
.../bindings/clock/airoha,en7523-scu.yaml | 101 +- .../bindings/phy/airoha,an7581-usb-phy.yaml | 83 ++ MAINTAINERS | 21 +- arch/arm64/boot/dts/airoha/en7581.dtsi | 49 + drivers/clk/clk-en7523.c | 340 +++-- drivers/phy/Kconfig | 11 +- drivers/phy/Makefile | 5 +- drivers/phy/airoha/Kconfig | 23 + drivers/phy/airoha/Makefile | 4 + drivers/phy/airoha/phy-airoha-pcie-regs.h | 494 +++++++ drivers/phy/airoha/phy-airoha-pcie.c | 1290 +++++++++++++++++ drivers/phy/airoha/phy-airoha-usb.c | 571 ++++++++ drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/airoha/Kconfig | 18 + drivers/soc/airoha/Makefile | 3 + drivers/soc/airoha/airoha-scu-ssr.c | 271 ++++ drivers/usb/host/Kconfig | 2 +- .../dt-bindings/phy/airoha,an7581-usb-phy.h | 11 + include/dt-bindings/soc/airoha,scu-ssr.h | 11 + include/linux/clk/clk-en7523.h | 10 + include/linux/soc/airoha/airoha-scu-ssr.h | 34 + 22 files changed, 3202 insertions(+), 152 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml create mode 100644 drivers/phy/airoha/Kconfig create mode 100644 drivers/phy/airoha/Makefile create mode 100644 drivers/phy/airoha/phy-airoha-pcie-regs.h create mode 100644 drivers/phy/airoha/phy-airoha-pcie.c create mode 100644 drivers/phy/airoha/phy-airoha-usb.c create mode 100644 drivers/soc/airoha/Kconfig create mode 100644 drivers/soc/airoha/Makefile create mode 100644 drivers/soc/airoha/airoha-scu-ssr.c create mode 100644 include/dt-bindings/phy/airoha,an7581-usb-phy.h create mode 100644 include/dt-bindings/soc/airoha,scu-ssr.h create mode 100644 include/linux/clk/clk-en7523.h create mode 100644 include/linux/soc/airoha/airoha-scu-ssr.h
Signature · 1 line
2.48.1
PATCH v2 1/11 clk: en7523: convert driver to regmap API
Convert driver to regmap API, in preparation for support of Airoha AN7583 as the SCU will be an MFD and the regmap will be provided in the parent node. Also Airoha EN7581 benefits from this in preparation of USB support that required checking and configuring SCU SSR bits.
While at it also cleanup some register mask and use bitfield macro.
--- drivers/clk/clk-en7523.c | 137 ++++++++++++++++++++++----------------- 1 file changed, 76 insertions(+), 61 deletions(-)
drivers/clk/clk-en7523.c +76 -61
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only +#include <linux/bitfield.h> #include <linux/delay.h> #include <linux/clk-provider.h> #include <linux/io.h>
@@ -34,6 +35,7 @@#define REG_RESET_CONTROL_PCIE2 BIT(26)/* EN7581 */ #define REG_NP_SCU_PCIC 0x88 +#define REG_PCIE_CTRL GENMASK(7, 0)#define REG_NP_SCU_SSTR 0x9c#define REG_PCIE_XSI0_SEL_MASK GENMASK(14, 13)#define REG_PCIE_XSI1_SEL_MASK GENMASK(12, 11)
@@ -63,14 +65,14 @@ struct en_clk_desc { };struct en_clk_gate { -void __iomem *base; +struct regmap *map;struct clk_hw hw; };struct en_rst_data {const u16 *bank_ofs;const u16 *idx_map; -void __iomem *base; +struct regmap *map;struct reset_controller_dev rcdev; };
@@ -388,44 +390,44 @@ static u32 en7523_get_div(const struct en_clk_desc *desc, u32 val)static int en7523_pci_is_enabled (struct clk_hw *hw) { struct en_clk_gate *cg = container_of(hw, struct en_clk_gate, hw); +u32 val; -return !!(readl (cg->base +REG_PCI_CONTROL ) ®_PCI_CONTROL_REFCLK_EN1 ); +regmap_read (cg->map,REG_PCI_CONTROL , &val); +return !!(val ®_PCI_CONTROL_REFCLK_EN1 ); }static int en7523_pci_prepare (struct clk_hw *hw) { struct en_clk_gate *cg = container_of(hw, struct en_clk_gate, hw); -void __iomem *np_base = cg->base; -u32 val, mask; +struct regmap *map = cg->map; +u32 mask;/* Need to pull device low before reset */ - val =readl (np_base +REG_PCI_CONTROL ); - val &= ~(REG_PCI_CONTROL_PERSTOUT1 |REG_PCI_CONTROL_PERSTOUT ); -writel (val, np_base +REG_PCI_CONTROL ); +regmap_clear_bits (map,REG_PCI_CONTROL , +REG_PCI_CONTROL_PERSTOUT1 | +REG_PCI_CONTROL_PERSTOUT );usleep_range (1000 ,2000 );/* Enable PCIe port 1 */ - val |=REG_PCI_CONTROL_REFCLK_EN1 ; -writel (val, np_base +REG_PCI_CONTROL ); +regmap_set_bits (map,REG_PCI_CONTROL , +REG_PCI_CONTROL_REFCLK_EN1 );usleep_range (1000 ,2000 );/* Reset to default */ - val =readl (np_base +REG_RESET_CONTROL1 ); mask =REG_RESET_CONTROL_PCIE1 |REG_RESET_CONTROL_PCIE2 |REG_RESET_CONTROL_PCIEHB ; -writel (val & ~mask, np_base +REG_RESET_CONTROL1 ); +regmap_clear_bits (map,REG_RESET_CONTROL1 , mask);usleep_range (1000 ,2000 ); -writel (val | mask, np_base +REG_RESET_CONTROL1 ); +regmap_set_bits (map,REG_RESET_CONTROL1 , mask);msleep (100 ); -writel (val & ~mask, np_base +REG_RESET_CONTROL1 ); +regmap_clear_bits (map,REG_RESET_CONTROL1 , mask);usleep_range (5000 ,10000 );/* Release device */ mask =REG_PCI_CONTROL_PERSTOUT1 |REG_PCI_CONTROL_PERSTOUT ; - val =readl (np_base +REG_PCI_CONTROL ); -writel (val & ~mask, np_base +REG_PCI_CONTROL ); +regmap_clear_bits (map,REG_PCI_CONTROL , mask);usleep_range (1000 ,2000 ); -writel (val | mask, np_base +REG_PCI_CONTROL ); +regmap_set_bits (map,REG_PCI_CONTROL , mask);msleep (250 );return 0 ;
@@ -434,16 +436,13 @@ static int en7523_pci_prepare(struct clk_hw *hw)static void en7523_pci_unprepare (struct clk_hw *hw) { struct en_clk_gate *cg = container_of(hw, struct en_clk_gate, hw); -void __iomem *np_base = cg->base; -u32 val; +struct regmap *map = cg->map; - val =readl (np_base +REG_PCI_CONTROL ); - val &= ~REG_PCI_CONTROL_REFCLK_EN1 ; -writel (val, np_base +REG_PCI_CONTROL ); +regmap_clear_bits (map,REG_PCI_CONTROL ,REG_PCI_CONTROL_REFCLK_EN1 ); }static struct clk_hw *en7523_register_pcie_clk (struct device *dev, -void __iomem *np_base) +struct regmap *clk_map) {const struct en_clk_soc_data *soc_data =device_get_match_data (dev);struct clk_init_data init = {
@@ -456,7 +455,7 @@ static struct clk_hw *en7523_register_pcie_clk(struct device *dev,if (!cg)return NULL ; - cg->base = np_base; + cg->map = clk_map; cg->hw.init = &init;if (init.ops->unprepare)
@@ -474,21 +473,20 @@ static int en7581_pci_is_enabled(struct clk_hw *hw)u32 val, mask; mask =REG_PCI_CONTROL_REFCLK_EN0 |REG_PCI_CONTROL_REFCLK_EN1 ; - val =readl (cg->base +REG_PCI_CONTROL ); +regmap_read (cg->map,REG_PCI_CONTROL , &val);return (val & mask) == mask; }static int en7581_pci_enable (struct clk_hw *hw) { struct en_clk_gate *cg = container_of(hw, struct en_clk_gate, hw); -void __iomem *np_base = cg->base; -u32 val, mask; +struct regmap *map = cg->map; +u32 mask; mask =REG_PCI_CONTROL_REFCLK_EN0 |REG_PCI_CONTROL_REFCLK_EN1 |REG_PCI_CONTROL_PERSTOUT1 |REG_PCI_CONTROL_PERSTOUT2 |REG_PCI_CONTROL_PERSTOUT ; - val =readl (np_base +REG_PCI_CONTROL ); -writel (val | mask, np_base +REG_PCI_CONTROL ); +regmap_set_bits (map,REG_PCI_CONTROL , mask);return 0 ; }
@@ -496,19 +494,18 @@ static int en7581_pci_enable(struct clk_hw *hw)static void en7581_pci_disable (struct clk_hw *hw) { struct en_clk_gate *cg = container_of(hw, struct en_clk_gate, hw); -void __iomem *np_base = cg->base; -u32 val, mask; +struct regmap *map = cg->map; +u32 mask; mask =REG_PCI_CONTROL_REFCLK_EN0 |REG_PCI_CONTROL_REFCLK_EN1 |REG_PCI_CONTROL_PERSTOUT1 |REG_PCI_CONTROL_PERSTOUT2 |REG_PCI_CONTROL_PERSTOUT ; - val =readl (np_base +REG_PCI_CONTROL ); -writel (val & ~mask, np_base +REG_PCI_CONTROL ); +regmap_clear_bits (map,REG_PCI_CONTROL , mask);usleep_range (1000 ,2000 ); }static void en7523_register_clocks (struct device *dev,struct clk_hw_onecell_data *clk_data, -void __iomem *base,void __iomem *np_base) +struct regmap *map,struct regmap *clk_map) {struct clk_hw *hw;u32 rate;
@@ -517,10 +514,12 @@ static void en7523_register_clocks(struct device *dev, struct clk_hw_onecell_datfor (i =0 ; i <ARRAY_SIZE (en7523_base_clks); i++) {const struct en_clk_desc *desc = &en7523_base_clks[i];u32 reg = desc->div_reg ? desc->div_reg : desc->base_reg; -u32 val =readl (base + desc->base_reg); +u32 val; + +regmap_read (map, desc->base_reg, &val); rate =en7523_get_base_rate (desc, val); - val =readl (base + reg); +regmap_read (map, reg, &val); rate /=en7523_get_div (desc, val); hw =clk_hw_register_fixed_rate (dev, desc->name,NULL ,0 , rate);
@@ -533,30 +532,47 @@ static void en7523_register_clocks(struct device *dev, struct clk_hw_onecell_dat clk_data->hws[desc->id] = hw; } - hw =en7523_register_pcie_clk (dev, np_base); + hw =en7523_register_pcie_clk (dev, clk_map); clk_data->hws[EN7523_CLK_PCIE ] = hw; } +static const struct regmap_config en7523_clk_regmap_config = { + .reg_bits =32 , + .val_bits =32 , + .reg_stride =4 , +}; +static int en7523_clk_hw_init (struct platform_device *pdev,struct clk_hw_onecell_data *clk_data) {void __iomem *base, *np_base; +struct regmap *map, *clk_map; base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (base))return PTR_ERR (base); + map =devm_regmap_init_mmio (&pdev->dev, base, + &en7523_clk_regmap_config); +if (IS_ERR (map)) +return PTR_ERR (map); + np_base =devm_platform_ioremap_resource (pdev,1 );if (IS_ERR (np_base))return PTR_ERR (np_base); -en7523_register_clocks (&pdev->dev, clk_data, base, np_base); + clk_map =devm_regmap_init_mmio (&pdev->dev, np_base, + &en7523_clk_regmap_config); +if (IS_ERR (clk_map)) +return PTR_ERR (clk_map); + +en7523_register_clocks (&pdev->dev, clk_data, map, clk_map);return 0 ; }static void en7581_register_clocks (struct device *dev,struct clk_hw_onecell_data *clk_data, -struct regmap *map,void __iomem *base) +struct regmap *map,struct regmap *clk_map) {struct clk_hw *hw;u32 rate;
@@ -593,7 +609,7 @@ static void en7581_register_clocks(struct device *dev, struct clk_hw_onecell_dat clk_data->hws[desc->id] = hw; } - hw =en7523_register_pcie_clk (dev, base); + hw =en7523_register_pcie_clk (dev, clk_map); clk_data->hws[EN7523_CLK_PCIE ] = hw; }
@@ -601,15 +617,10 @@ static int en7523_reset_update(struct reset_controller_dev *rcdev, unsigned long id, bool assert) { struct en_rst_data *rst_data = container_of(rcdev, struct en_rst_data, rcdev); -void __iomem *addr = rst_data->base + rst_data->bank_ofs[id /RST_NR_PER_BANK ]; -u32 val; +u32 addr = rst_data->bank_ofs[id /RST_NR_PER_BANK ]; - val =readl (addr); -if (assert) - val |=BIT (id %RST_NR_PER_BANK ); -else - val &= ~BIT (id %RST_NR_PER_BANK ); -writel (val, addr); +regmap_update_bits (rst_data->map, addr,BIT (id %RST_NR_PER_BANK ), + assert ?BIT (id %RST_NR_PER_BANK ) :0 );return 0 ; }
@@ -630,9 +641,11 @@ static int en7523_reset_status(struct reset_controller_dev *rcdev, unsigned long id) { struct en_rst_data *rst_data = container_of(rcdev, struct en_rst_data, rcdev); -void __iomem *addr = rst_data->base + rst_data->bank_ofs[id /RST_NR_PER_BANK ]; +u32 addr = rst_data->bank_ofs[id /RST_NR_PER_BANK ]; +u32 val; -return !!(readl (addr) &BIT (id %RST_NR_PER_BANK )); +regmap_read (rst_data->map, addr, &val); +return !!(val &BIT (id %RST_NR_PER_BANK )); } static int en7523_reset_xlate(struct reset_controller_dev *rcdev,
@@ -652,7 +665,7 @@ static const struct reset_control_ops en7581_reset_ops = { .status = en7523_reset_status, }; -static int en7581_reset_register (struct device *dev,void __iomem *base) +static int en7581_reset_register (struct device *dev,struct regmap *map) {struct en_rst_data *rst_data;
@@ -662,7 +675,7 @@ static int en7581_reset_register(struct device *dev, void __iomem *base) rst_data->bank_ofs = en7581_rst_ofs; rst_data->idx_map = en7581_rst_map; - rst_data->base = base; + rst_data->map = map; rst_data->rcdev.nr_resets =ARRAY_SIZE (en7581_rst_map); rst_data->rcdev.of_xlate = en7523_reset_xlate;
@@ -678,9 +691,8 @@ static int en7581_reset_register(struct device *dev, void __iomem *base)static int en7581_clk_hw_init (struct platform_device *pdev,struct clk_hw_onecell_data *clk_data) { -struct regmap *map; +struct regmap *map, *clk_map;void __iomem *base; -u32 val; map =syscon_regmap_lookup_by_compatible ("airoha,en7581-chip-scu" );if (IS_ERR (map))
@@ -690,15 +702,18 @@ static int en7581_clk_hw_init(struct platform_device *pdev,if (IS_ERR (base))return PTR_ERR (base); -en7581_register_clocks (&pdev->dev, clk_data, map, base); + clk_map =devm_regmap_init_mmio (&pdev->dev, base, &en7523_clk_regmap_config); +if (IS_ERR (clk_map)) +return PTR_ERR (clk_map); + +en7581_register_clocks (&pdev->dev, clk_data, map, clk_map); - val =readl (base +REG_NP_SCU_SSTR ); - val &= ~(REG_PCIE_XSI0_SEL_MASK |REG_PCIE_XSI1_SEL_MASK ); -writel (val, base +REG_NP_SCU_SSTR ); - val =readl (base +REG_NP_SCU_PCIC ); -writel (val |3 , base +REG_NP_SCU_PCIC ); +regmap_clear_bits (clk_map,REG_NP_SCU_SSTR , +REG_PCIE_XSI0_SEL_MASK |REG_PCIE_XSI1_SEL_MASK ); +regmap_update_bits (clk_map,REG_NP_SCU_PCIC ,REG_PCIE_CTRL , +FIELD_PREP (REG_PCIE_CTRL ,3 )); -return en7581_reset_register (&pdev->dev, base); +return en7581_reset_register (&pdev->dev, clk_map); }static int en7523_clk_probe (struct platform_device *pdev)
Signature · 1 line
2.48.1
PATCH v2 2/11 clk: en7523: generalize register clocks function
In reply to Christian MarangiGeneralize register clocks function for Airoha EN7523 and EN7581 clocks driver. The same logic is applied for both clock hence code can be reduced and simplified by putting the base_clocks struct in the soc_data and passing that to a generic register clocks function.
There is always the pattern where the last clock is always the PCIe one.
--- drivers/clk/clk-en7523.c | 130 ++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 77 deletions(-)
drivers/clk/clk-en7523.c +53 -77
@@ -78,8 +78,10 @@ struct en_rst_data {struct en_clk_soc_data {u32 num_clocks; +const struct en_clk_desc *base_clks;const struct clk_ops pcie_ops;int (*hw_init)(struct platform_device *pdev, +const struct en_clk_soc_data *soc_data,struct clk_hw_onecell_data *clk_data); };
@@ -467,6 +469,50 @@ static struct clk_hw *en7523_register_pcie_clk(struct device *dev,return &cg->hw; } +static void en75xx_register_clocks (struct device *dev, +const struct en_clk_soc_data *soc_data, +struct clk_hw_onecell_data *clk_data, +struct regmap *map,struct regmap *clk_map) +{ +struct clk_hw *hw; +u32 rate; +int i; + +for (i =0 ; i < soc_data->num_clocks -1 ; i++) { +const struct en_clk_desc *desc = &soc_data->base_clks[i]; +u32 val, reg = desc->div_reg ? desc->div_reg : desc->base_reg; +int err; + + err =regmap_read (map, desc->base_reg, &val); +if (err) { +pr_err ("Failed reading fixed clk rate %s: %d\n" , + desc->name, err); +continue ; + } + rate =en7523_get_base_rate (desc, val); + + err =regmap_read (map, reg, &val); +if (err) { +pr_err ("Failed reading fixed clk div %s: %d\n" , + desc->name, err); +continue ; + } + rate /=en7523_get_div (desc, val); + + hw =clk_hw_register_fixed_rate (dev, desc->name,NULL ,0 , rate); +if (IS_ERR (hw)) { +pr_err ("Failed to register clk %s: %ld\n" , + desc->name,PTR_ERR (hw)); +continue ; + } + + clk_data->hws[desc->id] = hw; + } + + hw =en7523_register_pcie_clk (dev, clk_map); + clk_data->hws[soc_data->num_clocks] = hw; +} +static int en7581_pci_is_enabled (struct clk_hw *hw) { struct en_clk_gate *cg = container_of(hw, struct en_clk_gate, hw);
@@ -504,38 +550,6 @@ static void en7581_pci_disable(struct clk_hw *hw)usleep_range (1000 ,2000 ); } -static void en7523_register_clocks (struct device *dev,struct clk_hw_onecell_data *clk_data, -struct regmap *map,struct regmap *clk_map) -{ -struct clk_hw *hw; -u32 rate; -int i; - -for (i =0 ; i <ARRAY_SIZE (en7523_base_clks); i++) { -const struct en_clk_desc *desc = &en7523_base_clks[i]; -u32 reg = desc->div_reg ? desc->div_reg : desc->base_reg; -u32 val; - -regmap_read (map, desc->base_reg, &val); - - rate =en7523_get_base_rate (desc, val); -regmap_read (map, reg, &val); - rate /=en7523_get_div (desc, val); - - hw =clk_hw_register_fixed_rate (dev, desc->name,NULL ,0 , rate); -if (IS_ERR (hw)) { -pr_err ("Failed to register clk %s: %ld\n" , - desc->name,PTR_ERR (hw)); -continue ; - } - - clk_data->hws[desc->id] = hw; - } - - hw =en7523_register_pcie_clk (dev, clk_map); - clk_data->hws[EN7523_CLK_PCIE ] = hw; -} -static const struct regmap_config en7523_clk_regmap_config = { .reg_bits =32 , .val_bits =32 ,
@@ -543,6 +557,7 @@ static const struct regmap_config en7523_clk_regmap_config = { };static int en7523_clk_hw_init (struct platform_device *pdev, +const struct en_clk_soc_data *soc_data,struct clk_hw_onecell_data *clk_data) {void __iomem *base, *np_base;
@@ -566,53 +581,11 @@ static int en7523_clk_hw_init(struct platform_device *pdev,if (IS_ERR (clk_map))return PTR_ERR (clk_map); -en7523_register_clocks (&pdev->dev, clk_data, map, clk_map); +en75xx_register_clocks (&pdev->dev, soc_data, clk_data, map, clk_map);return 0 ; } -static void en7581_register_clocks (struct device *dev,struct clk_hw_onecell_data *clk_data, -struct regmap *map,struct regmap *clk_map) -{ -struct clk_hw *hw; -u32 rate; -int i; - -for (i =0 ; i <ARRAY_SIZE (en7581_base_clks); i++) { -const struct en_clk_desc *desc = &en7581_base_clks[i]; -u32 val, reg = desc->div_reg ? desc->div_reg : desc->base_reg; -int err; - - err =regmap_read (map, desc->base_reg, &val); -if (err) { -pr_err ("Failed reading fixed clk rate %s: %d\n" , - desc->name, err); -continue ; - } - rate =en7523_get_base_rate (desc, val); - - err =regmap_read (map, reg, &val); -if (err) { -pr_err ("Failed reading fixed clk div %s: %d\n" , - desc->name, err); -continue ; - } - rate /=en7523_get_div (desc, val); - - hw =clk_hw_register_fixed_rate (dev, desc->name,NULL ,0 , rate); -if (IS_ERR (hw)) { -pr_err ("Failed to register clk %s: %ld\n" , - desc->name,PTR_ERR (hw)); -continue ; - } - - clk_data->hws[desc->id] = hw; - } - - hw =en7523_register_pcie_clk (dev, clk_map); - clk_data->hws[EN7523_CLK_PCIE ] = hw; -} -static int en7523_reset_update (struct reset_controller_dev *rcdev,unsigned long id,bool assert) {
@@ -689,6 +662,7 @@ static int en7581_reset_register(struct device *dev, struct regmap *map) }static int en7581_clk_hw_init (struct platform_device *pdev, +const struct en_clk_soc_data *soc_data,struct clk_hw_onecell_data *clk_data) {struct regmap *map, *clk_map;
@@ -706,7 +680,7 @@ static int en7581_clk_hw_init(struct platform_device *pdev,if (IS_ERR (clk_map))return PTR_ERR (clk_map); -en7581_register_clocks (&pdev->dev, clk_data, map, clk_map); +en75xx_register_clocks (&pdev->dev, soc_data, clk_data, map, clk_map);regmap_clear_bits (clk_map,REG_NP_SCU_SSTR ,REG_PCIE_XSI0_SEL_MASK |REG_PCIE_XSI1_SEL_MASK );
@@ -732,7 +706,7 @@ static int en7523_clk_probe(struct platform_device *pdev)return -ENOMEM ; clk_data->num = soc_data->num_clocks; - r = soc_data->hw_init (pdev, clk_data); + r = soc_data->hw_init (pdev, soc_data, clk_data);if (r)return r;
@@ -740,6 +714,7 @@ static int en7523_clk_probe(struct platform_device *pdev) }static const struct en_clk_soc_data en7523_data = { + .base_clks = en7523_base_clks, .num_clocks =ARRAY_SIZE (en7523_base_clks) +1 , .pcie_ops = { .is_enabled = en7523_pci_is_enabled,
@@ -750,6 +725,7 @@ static const struct en_clk_soc_data en7523_data = { };static const struct en_clk_soc_data en7581_data = { + .base_clks = en7581_base_clks,/* We increment num_clocks by 1 to account for additional PCIe clock */ .num_clocks =ARRAY_SIZE (en7581_base_clks) +1 , .pcie_ops = {
Signature · 1 line
2.48.1
PATCH v2 3/11 dt-bindings: clock: en7523: add Documentation for Airoha AN7581 SCU SSR
In reply to Christian MarangiThe Airoha AN7581 SoC have in the SCU register space particular address that control how some peripheral are configured.
These are toggeled in the System Status Register and are used to toggle Serdes port for USB 3.0 mode or HSGMII, USB 3.0 mode or PCIe2 or setup port for PCIe mode or Ethrnet mode (HSGMII/USXGMII).
Modes are mutually exclusive and selecting one mode cause the other feature to not work (example a mode in USB 3.0 cause PCIe port 2 to not work) This depends also on what is physically connected to the Hardware and needs to correctly reflect the System Status Register bits.
Special care is needed for PCIe port 0 in 2 line mode that requires both WiFi1 and WiFi2 Serdes port set to PCIe0 2 Line mode.
Expose these configuration as an enum of strings in the SCU node and also add dt-bindings header to reference each serdes port in DT.
--- .../bindings/clock/airoha,en7523-scu.yaml | 101 ++++++++++++++++-- MAINTAINERS | 7 ++ include/dt-bindings/soc/airoha,scu-ssr.h | 11 ++ 3 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 include/dt-bindings/soc/airoha,scu-ssr.h
Documentation/devicetree/bindings/clock/airoha,en7523-scu.yaml +92 -9
@@ -9,6 +9,7 @@ title: EN7523 Clock maintainers: - Felix Fietkau <[email protected]> - John Crispin <[email protected]> + - Christian Marangi <[email protected]> description: | This node defines the System Control Unit of the EN7523 SoC,
@@ -26,6 +27,23 @@ description: | The clocks are provided inside a system controller node. + The System Control Unit may also set different mode for the Serdes ports + present on the SoC. + + These are toggeled in the System Status Register and are used to + toggle Serdes port for USB 3.0 mode or HSGMII, USB 3.0 mode or PCIe2 + or setup port for PCIe mode or Ethernet mode (HSGMII/USXGMII). + + Modes are mutually exclusive and selecting one mode cause the + other feature to not work (example a mode in USB 3.0 cause PCIe + port 2 to not work) This depends also on what is physically + connected to the Hardware and needs to correctly reflect the + System Status Register bits. + + Special care is needed for PCIe port 0 in 2 line mode that + requires both WiFi1 and WiFi2 Serdes port set to PCIe0 2 Line + mode. + properties: compatible: items:
@@ -49,6 +67,40 @@ properties: description: ID of the controller reset line const: 1 + airoha,serdes-wifi1: + description: Configure the WiFi1 Serdes port + $ref: /schemas/types.yaml#/definitions/string + enum: + - pcie0_x2 + - pcie0_x1 + - ethernet + default: pcie0_x1 + + airoha,serdes-wifi2: + description: Configure the WiFi2 Serdes port + $ref: /schemas/types.yaml#/definitions/string + enum: + - pcie0_x2 + - pcie1_x1 + - ethernet + default: pcie1_x1 + + airoha,serdes-usb1: + description: Configure the USB1 Serdes port + $ref: /schemas/types.yaml#/definitions/string + enum: + - usb3 + - ethernet + default: usb3 + + airoha,serdes-usb2: + description: Configure the USB2 Serdes port + $ref: /schemas/types.yaml#/definitions/string + enum: + - usb3 + - pcie2_x1 + default: usb3 + required: - compatible - reg
@@ -64,6 +116,12 @@ allOf: reg: minItems: 2 + airoha,serdes-wifi1: false + airoha,serdes-wifi2: false + + airoha,serdes-usb1: false + airoha,serdes-usb2: false + '#reset-cells': false - if:
@@ -75,6 +133,24 @@ allOf: reg: maxItems: 1 + - if: + properties: + airoha,serdes-wifi1: + const: pcie0_x2 + then: + properties: + airoha,serdes-wifi2: + const: pcie0_x2 + + - if: + properties: + airoha,serdes-wifi2: + const: pcie0_x2 + then: + properties: + airoha,serdes-wifi1: + const: pcie0_x2 + additionalProperties: false examples:
@@ -87,15 +163,22 @@ examples: #clock-cells = <1>; }; + # Example SCU node with Serdes set to PCIe0 to x2 mode + # and USB2 set to PCIe2 to x1 mode - | soc { - #address-cells = <2>; - #size-cells = <2>; - - scuclk: clock-controller@1fb00000 { - compatible = "airoha,en7581-scu"; - reg = <0x0 0x1fb00000 0x0 0x970>; - #clock-cells = <1>; - #reset-cells = <1>; - }; + #address-cells = <2>; + #size-cells = <2>; + + scuclk: clock-controller@1fb00000 { + compatible = "airoha,en7581-scu"; + reg = <0x0 0x1fb00000 0x0 0x970>; + + airoha,serdes-wifi1 = "pcie0_x2"; + airoha,serdes-wifi2 = "pcie0_x2"; + airoha,serdes-usb2 = "pcie2_x1"; + + #clock-cells = <1>; + #reset-cells = <1>; + }; };
MAINTAINERS +7 -0
@@ -736,6 +736,13 @@ F: Documentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml F: drivers/phy/phy-airoha-pcie-regs.h F: drivers/phy/phy-airoha-pcie.c +AIROHA SCU SSR DRIVER +M: Christian Marangi <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Maintained +F: Documentation/devicetree/bindings/soc/airoha/airoha,an7581-scu-ssr.yaml +F: include/dt-bindings/soc/airoha,scu-ssr.h + AIROHA SPI SNFI DRIVER M: Lorenzo Bianconi <[email protected]> M: Ray Liu <[email protected]>
include/dt-bindings/soc/airoha,scu-ssr.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ + +#ifndef __DT_BINDINGS_AIROHA_SCU_SSR_H +#define __DT_BINDINGS_AIROHA_SCU_SSR_H + +#define AIROHA_SCU_SERDES_WIFI1 0 +#define AIROHA_SCU_SERDES_WIFI2 1 +#define AIROHA_SCU_SERDES_USB1 2 +#define AIROHA_SCU_SERDES_USB2 3 + +#endif /* __DT_BINDINGS_AIROHA_SCU_SSR_H */
Signature · 1 line
2.48.1
Rob Herring
maintainerRe: [PATCH v2 03/11] dt-bindings: clock: en7523: add Documentation for Airoha AN7581 SCU SSR
Quoted 91 lines · Christian Marangi
The Airoha AN7581 SoC have in the SCU register space particular address that control how some peripheral are configured.
These are toggeled in the System Status Register and are used to toggle Serdes port for USB 3.0 mode or HSGMII, USB 3.0 mode or PCIe2 or setup port for PCIe mode or Ethrnet mode (HSGMII/USXGMII).
Modes are mutually exclusive and selecting one mode cause the other feature to not work (example a mode in USB 3.0 cause PCIe port 2 to not work) This depends also on what is physically connected to the Hardware and needs to correctly reflect the System Status Register bits.
Special care is needed for PCIe port 0 in 2 line mode that requires both WiFi1 and WiFi2 Serdes port set to PCIe0 2 Line mode.
Expose these configuration as an enum of strings in the SCU node and also add dt-bindings header to reference each serdes port in DT.
Signed-off-by Christian Marangi <[email protected]>--- .../bindings/clock/airoha,en7523-scu.yaml | 101 ++++++++++++++++-- MAINTAINERS | 7 ++ include/dt-bindings/soc/airoha,scu-ssr.h | 11 ++ 3 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 include/dt-bindings/soc/airoha,scu-ssr.hDocumentation/devicetree/bindings/clock/airoha,en7523-scu.yaml +41
-0@@ -9,6 +9,7 @@ title: EN7523 Clock maintainers: - Felix Fietkau <[email protected]> - John Crispin <[email protected]> + - Christian Marangi <[email protected]> description: | This node defines the System Control Unit of the EN7523 SoC,@@ -26,6 +27,23 @@ description: | The clocks are provided inside a system controller node. + The System Control Unit may also set different mode for the Serdes ports + present on the SoC. + + These are toggeled in the System Status Register and are used to + toggle Serdes port for USB 3.0 mode or HSGMII, USB 3.0 mode or PCIe2 + or setup port for PCIe mode or Ethernet mode (HSGMII/USXGMII). + + Modes are mutually exclusive and selecting one mode cause the + other feature to not work (example a mode in USB 3.0 cause PCIe + port 2 to not work) This depends also on what is physically + connected to the Hardware and needs to correctly reflect the + System Status Register bits. + + Special care is needed for PCIe port 0 in 2 line mode that + requires both WiFi1 and WiFi2 Serdes port set to PCIe0 2 Line + mode. + properties: compatible: items:@@ -49,6 +67,40 @@ properties: description: ID of the controller reset line const: 1 + airoha,serdes-wifi1: + description: Configure the WiFi1 Serdes port + $ref: /schemas/types.yaml#/definitions/string + enum: + - pcie0_x2 + - pcie0_x1 + - ethernet + default: pcie0_x1 + + airoha,serdes-wifi2: + description: Configure the WiFi2 Serdes port + $ref: /schemas/types.yaml#/definitions/string + enum: + - pcie0_x2 + - pcie1_x1 + - ethernet + default: pcie1_x1 + + airoha,serdes-usb1: + description: Configure the USB1 Serdes port + $ref: /schemas/types.yaml#/definitions/string + enum: + - usb3
Documentation/devicetree/bindings/clock/airoha,en7523-scu.yaml properties: · line 102
Quoted 10 lines
Documentation/devicetree/bindings/clock/airoha,en7523-scu.yaml +10
-0+ - ethernet + default: usb3 + + airoha,serdes-usb2: + description: Configure the USB2 Serdes port + $ref: /schemas/types.yaml#/definitions/string + enum: + - usb3 + - pcie2_x1 + default: usb3
Couldn't you make this a phy provider and use the mode flags in the phy cells?
Quoted 18 lines
Documentation/devicetree/bindings/clock/airoha,en7523-scu.yaml +7
-0+ required: - compatible - reg@@ -64,6 +116,12 @@ allOf: reg: minItems: 2 + airoha,serdes-wifi1: false + airoha,serdes-wifi2: false + + airoha,serdes-usb1: false + airoha,serdes-usb2: false + '#reset-cells': false - if:
Documentation/devicetree/bindings/clock/airoha,en7523-scu.yaml allOf: · line 139
Quoted 7 lines
Documentation/devicetree/bindings/clock/airoha,en7523-scu.yaml +4
-0@@ -75,6 +133,24 @@ allOf: reg: maxItems: 1 + - if: + properties: + airoha,serdes-wifi1: + const: pcie0_x2
This is also true if airoha,serdes-wifi1 is not present. Probably not what you intended.
Quoted 15 lines
Documentation/devicetree/bindings/clock/airoha,en7523-scu.yaml +14
-0+ then: + properties: + airoha,serdes-wifi2: + const: pcie0_x2 + + - if: + properties: + airoha,serdes-wifi2: + const: pcie0_x2 + then: + properties: + airoha,serdes-wifi1: + const: pcie0_x2 + additionalProperties: false
PATCH v2 4/11 soc: airoha: add support for configuring SCU SSR Serdes port
In reply to Christian MarangiAdd support for configuring SCU SSR Serdes port. Airoha AN7581 SoC can configure the different Serdes port by toggling bits in the SCU register space.
Port Serdes mode are mutually exclusive, force example the USB2 Serdes port can either used for USB 3.0 or PCIe 2 port. Enabling USB 3.0 makes the PCIe 2 to not work.
The current supported Serdes port are:
- WiFi 1 and defaults to PCIe0 1 line mode
- Wifi 2 and defaults to PCIe1 1 line mode
- USB 1 and defaults to USB 3.0 mode
- USB 2 and defaults to USB 3.0 mode
WiFi 1, WiFi 2 and USB 1 also support a particular Ethernet mode that can toggle between USXGMII or HSGMII mode (USB 1 only to HSGMII) Such mode doesn't configure bits as specific Ethernet PCS driver will take care of configuring the Serdes mode based on what is required.
This driver is to correctly setup these bits.
Single driver can't independently set the Serdes port mode as that would cause a conflict if someone declare, for example, in DT (and enable) PCIe 2 port and USB2 3.0 port.
--- MAINTAINERS | 2 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/airoha/Kconfig | 18 ++ drivers/soc/airoha/Makefile | 3 + drivers/soc/airoha/airoha-scu-ssr.c | 221 ++++++++++++++++++++++ include/linux/soc/airoha/airoha-scu-ssr.h | 23 +++ 7 files changed, 269 insertions(+) create mode 100644 drivers/soc/airoha/Kconfig create mode 100644 drivers/soc/airoha/Makefile create mode 100644 drivers/soc/airoha/airoha-scu-ssr.c create mode 100644 include/linux/soc/airoha/airoha-scu-ssr.h
MAINTAINERS +2 -0
@@ -741,7 +741,9 @@ M: Christian Marangi <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: Documentation/devicetree/bindings/soc/airoha/airoha,an7581-scu-ssr.yaml +F: drivers/soc/airoha/airoha-scu-ssr.c F: include/dt-bindings/soc/airoha,scu-ssr.h +F: include/linux/soc/airoha/airoha-scu-ssr.h AIROHA SPI SNFI DRIVER M: Lorenzo Bianconi <[email protected]>
drivers/soc/Kconfig +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only menu "SOC (System On Chip) specific Drivers" +source "drivers/soc/airoha/Kconfig" source "drivers/soc/amlogic/Kconfig" source "drivers/soc/apple/Kconfig" source "drivers/soc/aspeed/Kconfig"
drivers/soc/Makefile +1 -0
@@ -3,6 +3,7 @@ # Makefile for the Linux Kernel SOC specific device drivers. # +obj-y += airoha/ obj-y += apple/ obj-y += aspeed/ obj-$(CONFIG_ARCH_AT91) += atmel/
drivers/soc/airoha/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config AIROHA_SCU_SSR + tristate "Airoha SCU SSR Driver" + depends on ARCH_AIROHA || COMPILE_TEST + depends on OF + help + Say 'Y' here to add support for Airoha SCU SSR driver. + + Airoha SoC pheriperal (like USB/PCIe/Ethernet port) are + selected by toggling specific bit. Serdes Port line + are mutually exclusive such as selecting PCIe port 2 + disable support for USB port 2 3.0 mode. + + This driver is used to configure such bit and expose + an API to read the current status from a user of such + Serdes lines. +
drivers/soc/airoha/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_AIROHA_SCU_SSR) += airoha-scu-ssr.o
drivers/soc/airoha/airoha-scu-ssr.c new file +221 -0
221 lines not on this page · raw message
include/linux/soc/airoha/airoha-scu-ssr.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __AIROHA_SCU_SSR__ +#define __AIROHA_SCU_SSR__ + +enum airoha_scu_serdes_modes { +AIROHA_SCU_SERDES_MODE_PCIE0_X1 , +AIROHA_SCU_SERDES_MODE_PCIE0_X2 , +AIROHA_SCU_SERDES_MODE_PCIE1_X1 , +AIROHA_SCU_SERDES_MODE_PCIE2_X1 , +AIROHA_SCU_SERDES_MODE_USB3 , +AIROHA_SCU_SERDES_MODE_ETHERNET , +}; + +struct airoha_scu_ssr_serdes_info { +unsigned int *possible_modes; +unsigned int num_modes; +}; + +struct airoha_scu_ssr_data { +const struct airoha_scu_ssr_serdes_info *ports_info; +}; + +#endif
Signature · 1 line
2.48.1
Re: [PATCH v2 04/11] soc: airoha: add support for configuring SCU SSR Serdes port
Quoted 19 lines · Christian Marangi
Add support for configuring SCU SSR Serdes port. Airoha AN7581 SoC can configure the different Serdes port by toggling bits in the SCU register space.
Port Serdes mode are mutually exclusive, force example the USB2 Serdes port can either used for USB 3.0 or PCIe 2 port. Enabling USB 3.0 makes the PCIe 2 to not work.
The current supported Serdes port are:
- WiFi 1 and defaults to PCIe0 1 line mode
- Wifi 2 and defaults to PCIe1 1 line mode
- USB 1 and defaults to USB 3.0 mode
- USB 2 and defaults to USB 3.0 modeWiFi 1, WiFi 2 and USB 1 also support a particular Ethernet mode that can toggle between USXGMII or HSGMII mode (USB 1 only to HSGMII) Such mode doesn't configure bits as specific Ethernet PCS driver will take care of configuring the Serdes mode based on what is required.
Quoted 6 lines
This driver is to correctly setup these bits.
Single driver can't independently set the Serdes port mode as that would cause a conflict if someone declare, for example, in DT (and enable) PCIe 2 port and USB2 3.0 port.Signed-off-by Christian Marangi <[email protected]>
I think serdes drivers are usually implement in the drivers/phy layer, and I see there is already a drivers/phy/phy-airoha-pcie.c, which may or may not overlap with this one (I have not looked at the details).
Have you tried to use the phy subsystem interface here instead of creating a custom in-kernel interface?
Arnd
Re: [PATCH v2 04/11] soc: airoha: add support for configuring SCU SSR Serdes port
Quoted 27 lines · Arnd Bergmann
Quoted 19 lines · Christian Marangi
Add support for configuring SCU SSR Serdes port. Airoha AN7581 SoC can configure the different Serdes port by toggling bits in the SCU register space.
Port Serdes mode are mutually exclusive, force example the USB2 Serdes port can either used for USB 3.0 or PCIe 2 port. Enabling USB 3.0 makes the PCIe 2 to not work.
The current supported Serdes port are:
- WiFi 1 and defaults to PCIe0 1 line mode
- Wifi 2 and defaults to PCIe1 1 line mode
- USB 1 and defaults to USB 3.0 mode
- USB 2 and defaults to USB 3.0 modeWiFi 1, WiFi 2 and USB 1 also support a particular Ethernet mode that can toggle between USXGMII or HSGMII mode (USB 1 only to HSGMII) Such mode doesn't configure bits as specific Ethernet PCS driver will take care of configuring the Serdes mode based on what is required.
Quoted 6 lines
This driver is to correctly setup these bits.
Single driver can't independently set the Serdes port mode as that would cause a conflict if someone declare, for example, in DT (and enable) PCIe 2 port and USB2 3.0 port.Signed-off-by Christian Marangi <[email protected]>
Quoted 8 lines
I think serdes drivers are usually implement in the
drivers/phylayer, and I see there is already adrivers/phy/phy-airoha-pcie.c, which may or may not overlap with this one (I have not looked at the details).Have you tried to use the phy subsystem interface here instead of creating a custom in-kernel interface?
These really set 1-2 bit and I think PHY can't describe PCIe in x2 mode or in x1. Also I think PHY is used for more advanced stuff and usually have dedicated register/maps. This is really to configure 1-2 bit and provide the mode, nothing else... no enable, no power up.
Do you think a it's possible to implement a ""read-only"" PHY driver?
The PCIe x2 mode maybe can be modelled with
phy-cells = <2> and adding a extra entry to enforce x2 line mode?
But I feel it would be wrong to say that the SCU expose PHY as it won't be true.
Honestly we should really consider starting to implement a generic provider for these stuff... it's not the first time we have bit that configure part of the entire system.
For example this is very common for QCOM with TCSR and also for Mediatek with the TPHY. (but TPHY is at least more realistic as it can enable and disable serdes port... here it's just 1 bit)
Signature · 1 line
Ansuel
PATCH v2 5/11 clk: en7523: define and register SoC SCU SSR driver for EN7581
In reply to Christian MarangiDefine all the possible interface modes and register the SoC SCU SSR platform driver for EN7581.
Failing to register the SCU SSR driver is not a critical error (example the SoC driver is not enable) but will prevent PCIe or USB port to function correctly.
Reference to the SSR pdev are stored in the new en7523 priv struct.
--- drivers/clk/clk-en7523.c | 99 ++++++++++++++++++++++++++++++++-- include/linux/clk/clk-en7523.h | 10 ++++ 2 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 include/linux/clk/clk-en7523.h
drivers/clk/clk-en7523.c +96 -3
@@ -3,14 +3,17 @@#include <linux/bitfield.h> #include <linux/delay.h> #include <linux/clk-provider.h> +#include <linux/clk/clk-en7523.h> #include <linux/io.h> #include <linux/mfd/syscon.h> #include <linux/platform_device.h> #include <linux/property.h> #include <linux/regmap.h> #include <linux/reset-controller.h> +#include <linux/soc/airoha/airoha-scu-ssr.h> #include <dt-bindings/clock/en7523-clk.h> #include <dt-bindings/reset/airoha,en7581-reset.h> +#include <dt-bindings/soc/airoha,scu-ssr.h> #define RST_NR_PER_BANK 32
@@ -81,6 +84,7 @@ struct en_clk_soc_data {const struct en_clk_desc *base_clks;const struct clk_ops pcie_ops;int (*hw_init)(struct platform_device *pdev, +struct en_clk_priv *priv,const struct en_clk_soc_data *soc_data,struct clk_hw_onecell_data *clk_data); };
@@ -361,6 +365,51 @@ static const u16 en7581_rst_map[] = { [EN7581_XPON_MAC_RST] = RST_NR_PER_BANK + 31, }; +static unsigned int an7581_serdes_wifi1_possible_modes[] = { +AIROHA_SCU_SERDES_MODE_PCIE0_X1 , +AIROHA_SCU_SERDES_MODE_PCIE0_X2 , +AIROHA_SCU_SERDES_MODE_ETHERNET , +}; + +static unsigned int an7581_serdes_wifi2_possible_modes[] = { +AIROHA_SCU_SERDES_MODE_PCIE1_X1 , +AIROHA_SCU_SERDES_MODE_PCIE0_X2 , +AIROHA_SCU_SERDES_MODE_ETHERNET , +}; + +static unsigned int an7581_serdes_usb1_possible_modes[] = { +AIROHA_SCU_SERDES_MODE_USB3 , +AIROHA_SCU_SERDES_MODE_ETHERNET , +}; + +static unsigned int an7581_serdes_usb2_possible_modes[] = { +AIROHA_SCU_SERDES_MODE_PCIE2_X1 , +AIROHA_SCU_SERDES_MODE_ETHERNET , +}; + +static const struct airoha_scu_ssr_serdes_info an7581_ports_info[] = { + [AIROHA_SCU_SERDES_WIFI1 ] = { + .possible_modes = an7581_serdes_wifi1_possible_modes, + .num_modes =ARRAY_SIZE (an7581_serdes_wifi1_possible_modes), + }, + [AIROHA_SCU_SERDES_WIFI2 ] = { + .possible_modes = an7581_serdes_wifi2_possible_modes, + .num_modes =ARRAY_SIZE (an7581_serdes_wifi2_possible_modes), + }, + [AIROHA_SCU_SERDES_USB1 ] = { + .possible_modes = an7581_serdes_usb1_possible_modes, + .num_modes =ARRAY_SIZE (an7581_serdes_usb1_possible_modes), + }, + [AIROHA_SCU_SERDES_USB2 ] = { + .possible_modes = an7581_serdes_usb2_possible_modes, + .num_modes =ARRAY_SIZE (an7581_serdes_usb2_possible_modes), + }, +}; + +static const struct airoha_scu_ssr_data an7581_scu_ssr_data = { + .ports_info = an7581_ports_info, +}; +static u32 en7523_get_base_rate (const struct en_clk_desc *desc,u32 val) {if (!desc->base_bits)
@@ -557,6 +606,7 @@ static const struct regmap_config en7523_clk_regmap_config = { };static int en7523_clk_hw_init (struct platform_device *pdev, +struct en_clk_priv *priv,const struct en_clk_soc_data *soc_data,struct clk_hw_onecell_data *clk_data) {
@@ -661,12 +711,38 @@ static int en7581_reset_register(struct device *dev, struct regmap *map)return devm_reset_controller_register (dev, &rst_data->rcdev); } +static void en7581_clk_register_ssr (struct platform_device *pdev, +struct en_clk_priv *priv) +{ +struct platform_device_info pinfo = { }; +struct platform_device *ssr_pdev; + + pinfo.name ="airoha-scu-ssr" ; + pinfo.parent = &pdev->dev; + pinfo.id =PLATFORM_DEVID_AUTO ; + pinfo.fwnode =of_fwnode_handle (pdev->dev.of_node); + pinfo.of_node_reused = true; + pinfo.data = &an7581_scu_ssr_data; + pinfo.size_data =sizeof (an7581_scu_ssr_data); + + ssr_pdev =platform_device_register_data (&pdev->dev,"airoha-scu-ssr" , +PLATFORM_DEVID_AUTO , + &an7581_scu_ssr_data, +sizeof (an7581_scu_ssr_data)); +if (IS_ERR (ssr_pdev)) +dev_warn_probe (&pdev->dev,PTR_ERR (ssr_pdev),"failed to register SCU SSR driver.\n" ); + + priv->ssr_pdev = ssr_pdev; +} +static int en7581_clk_hw_init (struct platform_device *pdev, +struct en_clk_priv *priv,const struct en_clk_soc_data *soc_data,struct clk_hw_onecell_data *clk_data) {struct regmap *map, *clk_map;void __iomem *base; +int ret; map =syscon_regmap_lookup_by_compatible ("airoha,en7581-chip-scu" );if (IS_ERR (map))
@@ -687,7 +763,13 @@ static int en7581_clk_hw_init(struct platform_device *pdev,regmap_update_bits (clk_map,REG_NP_SCU_PCIC ,REG_PCIE_CTRL ,FIELD_PREP (REG_PCIE_CTRL ,3 )); -return en7581_reset_register (&pdev->dev, clk_map); + ret =en7581_reset_register (&pdev->dev, clk_map); +if (ret) +return ret; + +en7581_clk_register_ssr (pdev, priv); + +return 0 ; }static int en7523_clk_probe (struct platform_device *pdev)
@@ -695,10 +777,15 @@ static int en7523_clk_probe(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;const struct en_clk_soc_data *soc_data;struct clk_hw_onecell_data *clk_data; +struct en_clk_priv *priv;int r; soc_data =device_get_match_data (&pdev->dev); + priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + clk_data =devm_kzalloc (&pdev->dev,struct_size (clk_data, hws, soc_data->num_clocks),GFP_KERNEL );
@@ -706,11 +793,17 @@ static int en7523_clk_probe(struct platform_device *pdev)return -ENOMEM ; clk_data->num = soc_data->num_clocks; - r = soc_data->hw_init (pdev, soc_data, clk_data); + r = soc_data->hw_init (pdev, priv, soc_data, clk_data);if (r)return r; -return of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); + r =of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); +if (r) +return r; + +platform_set_drvdata (pdev, priv); + +return 0 ; }static const struct en_clk_soc_data en7523_data = {
include/linux/clk/clk-en7523.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef __LINUX_CLK_EN7523_H_ +#define __LINUX_CLK_EN7523_H_ + +struct en_clk_priv { +struct platform_device *ssr_pdev; +}; + +#endif
Signature · 1 line
2.48.1
PATCH v2 6/11 soc: airoha: scu-ssr: expose API to read current Serdes Port mode
In reply to Christian MarangiExpose an API to read the current Serdes Port mode. This is needed for pheriperal attached to the Serdes mode to validate the Serdes port is in the correct mode.
Each driver will have to define in DT the phandle airoha,scu pointing to the SCU node to make use of this API.
Function airoha_scu_ssr_get_serdes_mode() will then parse the phandle, and extract tha Serdes Port state from the SCU SSR driver priv.
Driver will use the new API airoha_scu_ssr_get_serdes_mode() by passing the dev and the serdes mode reference from dt-bindings header.
--- drivers/soc/airoha/airoha-scu-ssr.c | 50 +++++++++++++++++++++++ include/linux/soc/airoha/airoha-scu-ssr.h | 11 +++++ 2 files changed, 61 insertions(+)
drivers/soc/airoha/airoha-scu-ssr.c +50 -0
@@ -5,6 +5,7 @@#include <dt-bindings/soc/airoha,scu-ssr.h> #include <linux/bitfield.h> +#include <linux/clk/clk-en7523.h> #include <linux/of.h> #include <linux/of_platform.h> #include <linux/platform_device.h>
@@ -54,6 +55,55 @@ static int airoha_scu_serdes_str_to_mode(const char *serdes_str)return -EINVAL ; } +/** +* airoha_scu_ssr_get_serdes_mode - Get current Mode for Serdes Port +* @dev: Device pointer of the Serdes Port peripheral +* @port: Reference number of the Serdes Port +* +* Parse the phandle pointed by the Device Node property +* "airoha,scu" present in Devide Node of dev and get +* the current Mode of the Serdes Port reference by port +* +* Return the mode or a negative error code. If the pdev +* or the driver data for the SCU can't be found, +* -EPROBE_DEFER is returned. +*/ +int airoha_scu_ssr_get_serdes_mode (struct device *dev, +unsigned int port) +{ +struct airoha_scu_ssr_priv *priv; +struct en_clk_priv *clk_priv; +struct platform_device *pdev; +struct device_node *np; + + np =of_parse_phandle (dev->of_node,"airoha,scu" ,0 ); +if (!np) +return -ENODEV ; + +if (!of_device_is_available (np)) { +of_node_put (np); +return -ENODEV ; + } + + pdev =of_find_device_by_node (np); +of_node_put (np); +if (!pdev || !platform_get_drvdata (pdev)) { +if (pdev) +put_device (&pdev->dev); +return -EPROBE_DEFER ; + } + +/* +* Get pdev from clk priv. Clock driver register +* SSR driver hence it can be assumed present. +*/ + clk_priv =platform_get_drvdata (pdev); + priv =platform_get_drvdata (clk_priv->ssr_pdev); + +return priv->serdes_port[port]; +} +EXPORT_SYMBOL_GPL (airoha_scu_ssr_get_serdes_mode); +static int airoha_scu_ssr_apply_modes (struct airoha_scu_ssr_priv *priv) {int ret;
include/linux/soc/airoha/airoha-scu-ssr.h +11 -0
@@ -20,4 +20,15 @@ struct airoha_scu_ssr_data { const struct airoha_scu_ssr_serdes_info *ports_info; }; +#if IS_ENABLED (CONFIG_AIROHA_SCU_SSR ) +int airoha_scu_ssr_get_serdes_mode (struct device *dev, +unsigned int port); +#else +static inline int airoha_scu_ssr_get_serdes_mode (struct device *dev, +unsigned int port); +{ +return -EOPNOTSUPP ; +} +#endif +#endif
Signature · 1 line
2.48.1
PATCH v2 7/11 dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY
In reply to Christian MarangiAdd documentation for Airoha AN7581 USB PHY that describe the USB PHY for the USB controller.
Airoha AN7581 SoC support a maximum of 2 USB port. The USB 2.0 mode is always supported. The USB 3.0 mode is optional and depends on the Serdes mode currently configured on the system for the USB port.
If the airoha,serdes-port property is not declared, it's assumed USB 3.0 mode is not supported, as the Serdes mode can't be validated.
--- .../bindings/phy/airoha,an7581-usb-phy.yaml | 83 +++++++++++++++++++ MAINTAINERS | 7 ++ .../dt-bindings/phy/airoha,an7581-usb-phy.h | 11 +++ 3 files changed, 101 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml create mode 100644 include/dt-bindings/phy/airoha,an7581-usb-phy.h
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml new file +83 -0
@@ -0,0 +1,83 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/airoha,an7581-usb-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha AN7581 SoC USB PHY + +maintainers: + - Christian Marangi <[email protected]> + +description: > + The Airoha AN7581 SoC USB PHY describes the USB PHY for the USB controller. + + Airoha AN7581 SoC support a maximum of 2 USB port. The USB 2.0 mode is + always supported. The USB 3.0 mode is optional and depends on the Serdes + mode currently configured on the system for the USB port. + + If the airoha,serdes-port property is not declared, it's assumed USB 3.0 + mode is not supported, as the Serdes mode can't be validated. + +properties: + compatible: + const: airoha,an7581-usb-phy + + reg: + maxItems: 1 + + + airoha,usb2-monitor-clk-sel: + description: Describe what oscillator across the available 4 + should be selected for USB 2.0 Slew Rate calibration. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + + airoha,serdes-port: + description: Describe what Serdes Port is attached to the USB 3.0 port. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + + airoha,scu: + description: Phandle to the SCU node for USB 3.0 Serdes mode validation. + $ref: /schemas/types.yaml#/definitions/phandle + + '#phy-cells': + const: 1 + +required: + - compatible + - reg + - airoha,usb2-monitor-clk-sel + - '#phy-cells' + +dependentRequired: + airoha,serdes-port: [ 'airoha,scu' ] + +additionalProperties: false + +examples: + - | + #include <dt-bindings/phy/airoha,an7581-usb-phy.h> + #include <dt-bindings/soc/airoha,scu-ssr.h> + + phy@1fac0000 { + compatible = "airoha,an7581-usb-phy"; + reg = <0x1fac0000 0x10000>; + + airoha,usb2-monitor-clk-sel = <AIROHA_USB2_MONCLK_SEL1>; + airoha,scu = <&scu>; + airoha,serdes-port = <AIROHA_SCU_SERDES_USB1>; + + #phy-cells = <1>; + }; + + phy@1fae0000 { + compatible = "airoha,an7581-usb-phy"; + reg = <0x1fae0000 0x10000>; + + airoha,usb2-monitor-clk-sel = <AIROHA_USB2_MONCLK_SEL2>; + + #phy-cells = <1>; + }; +
MAINTAINERS +7 -0
@@ -754,6 +754,13 @@ S: Maintained F: Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml F: drivers/spi/spi-airoha-snfi.c +AIROHA USB PHY DRIVER +M: Christian Marangi <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Maintained +F: Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml +F: include/dt-bindings/phy/airoha,an7581-usb-phy.h + AIRSPY MEDIA DRIVER L: [email protected] S: Orphan
include/dt-bindings/phy/airoha,an7581-usb-phy.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause */ + +#ifndef _DT_BINDINGS_AIROHA_AN7581_USB_PHY_H_ +#define _DT_BINDINGS_AIROHA_AN7581_USB_PHY_H_ + +#define AIROHA_USB2_MONCLK_SEL0 0 +#define AIROHA_USB2_MONCLK_SEL1 1 +#define AIROHA_USB2_MONCLK_SEL2 2 +#define AIROHA_USB2_MONCLK_SEL3 3 + +#endif
Signature · 1 line
2.48.1
Rob Herring
maintainerRe: [PATCH v2 07/11] dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY
Quoted 54 lines · Christian Marangi
Add documentation for Airoha AN7581 USB PHY that describe the USB PHY for the USB controller.
Airoha AN7581 SoC support a maximum of 2 USB port. The USB 2.0 mode is always supported. The USB 3.0 mode is optional and depends on the Serdes mode currently configured on the system for the USB port.
If the airoha,serdes-port property is not declared, it's assumed USB 3.0 mode is not supported, as the Serdes mode can't be validated.
Signed-off-by Christian Marangi <[email protected]>--- .../bindings/phy/airoha,an7581-usb-phy.yaml | 83 +++++++++++++++++++ MAINTAINERS | 7 ++ .../dt-bindings/phy/airoha,an7581-usb-phy.h | 11 +++ 3 files changed, 101 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml create mode 100644 include/dt-bindings/phy/airoha,an7581-usb-phy.hDocumentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml new file +29
-0@@ -0,0 +1,83 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/airoha,an7581-usb-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha AN7581 SoC USB PHY + +maintainers: + - Christian Marangi <[email protected]> + +description: > + The Airoha AN7581 SoC USB PHY describes the USB PHY for the USB controller. + + Airoha AN7581 SoC support a maximum of 2 USB port. The USB 2.0 mode is + always supported. The USB 3.0 mode is optional and depends on the Serdes + mode currently configured on the system for the USB port. + + If the airoha,serdes-port property is not declared, it's assumed USB 3.0 + mode is not supported, as the Serdes mode can't be validated. + +properties: + compatible: + const: airoha,an7581-usb-phy + + reg: + maxItems: 1 + +
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml line 39
Quoted 10 lines
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml new file +10
-0+ airoha,usb2-monitor-clk-sel: + description: Describe what oscillator across the available 4 + should be selected for USB 2.0 Slew Rate calibration. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + + airoha,serdes-port: + description: Describe what Serdes Port is attached to the USB 3.0 port. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3]
Since you only have a single value here, does that mean only only one of the 2 ports/phys supports USB3?
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml line 43
Quoted 4 lines
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml new file +4
-0+ + airoha,scu: + description: Phandle to the SCU node for USB 3.0 Serdes mode validation. + $ref: /schemas/types.yaml#/definitions/phandle
A bit unusual, but you could use the phys binding here instead of these 2 properties. The phy for the phy...
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml line 46
Quoted 3 lines
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml new file +3
-0+ + '#phy-cells': + const: 1
Please add a description of what's in the cell.
Quoted 26 lines
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml new file +26
-0+ +required: + - compatible + - reg + - airoha,usb2-monitor-clk-sel + - '#phy-cells' + +dependentRequired: + airoha,serdes-port: [ 'airoha,scu' ] + +additionalProperties: false + +examples: + - | + #include <dt-bindings/phy/airoha,an7581-usb-phy.h> + #include <dt-bindings/soc/airoha,scu-ssr.h> + + phy@1fac0000 { + compatible = "airoha,an7581-usb-phy"; + reg = <0x1fac0000 0x10000>; + + airoha,usb2-monitor-clk-sel = <AIROHA_USB2_MONCLK_SEL1>; + airoha,scu = <&scu>; + airoha,serdes-port = <AIROHA_SCU_SERDES_USB1>; + + #phy-cells = <1>;
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml line 82
Quoted 10 lines
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml new file +10
-0+ }; + + phy@1fae0000 { + compatible = "airoha,an7581-usb-phy"; + reg = <0x1fae0000 0x10000>; + + airoha,usb2-monitor-clk-sel = <AIROHA_USB2_MONCLK_SEL2>; + + #phy-cells = <1>; + };
Drop the 2nd example.
Rob
PATCH v2 8/11 phy: move Airoha PCIe PHY driver to dedicated directory
In reply to Christian MarangiTo keep the generic PHY directory tidy, move the PCIe PHY driver to a dedicated directory.
This is also in preparation for support of the Airoha USB PHY driver.
--- MAINTAINERS | 4 +- drivers/phy/Kconfig | 11 +- drivers/phy/Makefile | 5 +- drivers/phy/airoha/Kconfig | 13 + drivers/phy/airoha/Makefile | 3 + drivers/phy/airoha/phy-airoha-pcie-regs.h | 494 ++++++++ drivers/phy/airoha/phy-airoha-pcie.c | 1290 +++++++++++++++++++++ 7 files changed, 1806 insertions(+), 14 deletions(-) create mode 100644 drivers/phy/airoha/Kconfig create mode 100644 drivers/phy/airoha/Makefile create mode 100644 drivers/phy/airoha/phy-airoha-pcie-regs.h create mode 100644 drivers/phy/airoha/phy-airoha-pcie.c
MAINTAINERS +2 -2
@@ -733,8 +733,8 @@ M: Lorenzo Bianconi <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: Documentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml -F: drivers/phy/phy-airoha-pcie-regs.h -F: drivers/phy/phy-airoha-pcie.c +F: drivers/phy/airoha/phy-airoha-pcie-regs.h +F: drivers/phy/airoha/phy-airoha-pcie.c AIROHA SCU SSR DRIVER M: Christian Marangi <[email protected]>
drivers/phy/Kconfig +1 -10
@@ -72,16 +72,6 @@ config PHY_CAN_TRANSCEIVER functional modes using gpios and sets the attribute max link rate, for CAN drivers. -config PHY_AIROHA_PCIE - tristate "Airoha PCIe-PHY Driver" - depends on ARCH_AIROHA || COMPILE_TEST - depends on OF - select GENERIC_PHY - help - Say Y here to add support for Airoha PCIe PHY driver. - This driver create the basic PHY instance and provides initialize - callback for PCIe GEN3 port. - config PHY_NXP_PTN3222 tristate "NXP PTN3222 1-port eUSB2 to USB2 redriver" depends on I2C
@@ -93,6 +83,7 @@ config PHY_NXP_PTN3222 schemes. It supports all three USB 2.0 data rates: Low Speed, Full Speed and High Speed. +source "drivers/phy/airoha/Kconfig" source "drivers/phy/allwinner/Kconfig" source "drivers/phy/amlogic/Kconfig" source "drivers/phy/broadcom/Kconfig"
drivers/phy/Makefile +3 -2
@@ -10,9 +10,10 @@ 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_AIROHA_PCIE) += phy-airoha-pcie.o + obj-$(CONFIG_PHY_NXP_PTN3222) += phy-nxp-ptn3222.o -obj-y += allwinner/ \ +obj-y += airoha/ \ + allwinner/ \ amlogic/ \ broadcom/ \ cadence/ \
drivers/phy/airoha/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Phy drivers for Airoha devices +# +config PHY_AIROHA_PCIE + tristate "Airoha PCIe-PHY Driver" + depends on ARCH_AIROHA || COMPILE_TEST + depends on OF + select GENERIC_PHY + help + Say Y here to add support for Airoha PCIe PHY driver. + This driver create the basic PHY instance and provides initialize + callback for PCIe GEN3 port.
drivers/phy/airoha/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_PHY_AIROHA_PCIE) += phy-airoha-pcie.o
drivers/phy/airoha/phy-airoha-pcie-regs.h new file +494 -0
494 lines not on this page · raw message
drivers/phy/airoha/phy-airoha-pcie.c new file +1290 -0
1,290 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH v2 9/11 phy: airoha: Add support for Airoha AN7581 USB PHY
In reply to Christian MarangiAdd support for Airoha AN7581 USB PHY driver. AN7581 supports up to 2 USB port with USB 2.0 mode always supported and USB 3.0 mode available only if the Serdes port is correctly configured for USB 3.0.
On xLate probe, the Serdes mode is validated and the driver return error if the Serdes mode doesn't reflect the expected mode. This is required as Serdes mode are controlled by the SCU SSR bits and can be either USB 3.0 mode or HSGMII or PCIe 2. In such case USB 3.0 won't work.
If the USB 3.0 mode is not supported, the modes needs to be also disabled in the xHCI node or the driver will report unsable clock and fail probe.
Also USB 3.0 PHY instance are provided only if the airoha,serdes-port property is defined in DT, if it's not then USB 3.0 PHY is assumed not supported.
For USB 2.0 Slew Rate calibration, airoha,usb2-monitor-clk-sel is mandatory and is used to select the monitor clock for calibration.
Normally it's 1 for USB port 1 and 2 for USB port 2.
--- MAINTAINERS | 1 + drivers/phy/airoha/Kconfig | 10 + drivers/phy/airoha/Makefile | 1 + drivers/phy/airoha/phy-airoha-usb.c | 571 ++++++++++++++++++++++++++++ 4 files changed, 583 insertions(+) create mode 100644 drivers/phy/airoha/phy-airoha-usb.c
MAINTAINERS +1 -0
@@ -759,6 +759,7 @@ M: Christian Marangi <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml +F: drivers/phy/airoha/phy-airoha-usb.c F: include/dt-bindings/phy/airoha,an7581-usb-phy.h AIRSPY MEDIA DRIVER
drivers/phy/airoha/Kconfig +10 -0
@@ -11,3 +11,13 @@ config PHY_AIROHA_PCIE Say Y here to add support for Airoha PCIe PHY driver. This driver create the basic PHY instance and provides initialize callback for PCIe GEN3 port. + +config PHY_AIROHA_USB + tristate "Airoha USB PHY Driver" + depends on ARCH_AIROHA || COMPILE_TEST + depends on OF + select GENERIC_PHY + help + Say 'Y' here to add support for Airoha USB PHY driver. + This driver create the basic PHY instance and provides initialize + callback for USB port.
drivers/phy/airoha/Makefile +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_PHY_AIROHA_PCIE) += phy-airoha-pcie.o +obj-$(CONFIG_PHY_AIROHA_USB) += phy-airoha-usb.o
drivers/phy/airoha/phy-airoha-usb.c new file +571 -0
571 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH v2 10/11 usb: host: add ARCH_AIROHA in XHCI MTK dependency
In reply to Christian MarangiAiroha SoC use the same register map a logic of the Mediatek xHCI driver, hence add it to the dependency list to permit compilation also on this ARCH.
--- drivers/usb/host/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/Kconfig +1 -1
@@ -71,7 +71,7 @@ config USB_XHCI_HISTB config USB_XHCI_MTK tristate "xHCI support for MediaTek SoCs" select MFD_SYSCON - depends on (MIPS && SOC_MT7621) || ARCH_MEDIATEK || COMPILE_TEST + depends on (MIPS && SOC_MT7621) || ARCH_MEDIATEK || ARCH_AIROHA || COMPILE_TEST help Say 'Y' to enable the support for the xHCI host controller found in MediaTek SoCs.
Signature · 1 line
2.48.1
PATCH v2 11/11 arm64: dts: airoha: en7581: add USB nodes
In reply to Christian MarangiAdd USB nodes required for USB support of Airoha EN7581 with the correct define of Serdes Port and Monitor Clock for USB 2.0 calibration.
--- arch/arm64/boot/dts/airoha/en7581.dtsi | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
arch/arm64/boot/dts/airoha/en7581.dtsi +49 -0
@@ -3,7 +3,10 @@ #include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/clock/en7523-clk.h> +#include <dt-bindings/phy/phy.h> +#include <dt-bindings/phy/airoha,an7581-usb-phy.h> #include <dt-bindings/reset/airoha,en7581-reset.h> +#include <dt-bindings/soc/airoha,scu-ssr.h> / { interrupt-parent = <&gic>;
@@ -195,6 +198,52 @@ rng@1faa1000 { interrupts = <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>; }; + usb0: usb@1fab0000 { + compatible = "mediatek,mtk-xhci"; + reg = <0x0 0x1fab0000 0x0 0x3e00>, + <0x0 0x1fab3e00 0x0 0x100>; + reg-names = "mac", "ippc"; + interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>; + + phys = <&usb0_phy PHY_TYPE_USB2>, <&usb0_phy PHY_TYPE_USB3>; + + status = "disabled"; + }; + + usb0_phy: phy@1fac0000 { + compatible = "airoha,an7581-usb-phy"; + reg = <0x0 0x1fac0000 0x0 0x10000>; + + airoha,scu = <&scuclk>; + airoha,usb2-monitor-clk-sel = <AIROHA_USB2_MONCLK_SEL1>; + airoha,serdes-port = <AIROHA_SCU_SERDES_USB1>; + + #phy-cells = <1>; + }; + + usb1: usb@1fad0000 { + compatible = "mediatek,mtk-xhci"; + reg = <0x0 0x1fad0000 0x0 0x3e00>, + <0x0 0x1fad3e00 0x0 0x100>; + reg-names = "mac", "ippc"; + interrupts = <GIC_SPI 150 IRQ_TYPE_LEVEL_HIGH>; + + phys = <&usb1_phy PHY_TYPE_USB2>, <&usb1_phy PHY_TYPE_USB3>; + + status = "disabled"; + }; + + usb1_phy: phy@1fae0000 { + compatible = "airoha,an7581-usb-phy"; + reg = <0x0 0x1fae0000 0x0 0x10000>; + + airoha,scu = <&scuclk>; + airoha,usb2-monitor-clk-sel = <AIROHA_USB2_MONCLK_SEL2>; + airoha,serdes-port = <AIROHA_SCU_SERDES_USB2>; + + #phy-cells = <1>; + }; + system-controller@1fbf0200 { compatible = "airoha,en7581-gpio-sysctl", "syscon", "simple-mfd";
Signature · 1 line
2.48.1
Rob Herring (Arm)
maintainerQuoted 81 lines · Christian Marangi
This series implement all the changes required to correctly handle USB support for the Airoha EN7581 SoC.
The first few patch are cleanup for the clock driver and the introduction of the SCU SSR SoC driver.
The SoC always support USB 2.0 but for USB 3.0 it needs additional configuration for the Serdes port. Such port can be either configured for USB usage or for PCIe lines or HSGMII and these are configured in the SCU space.
The xHCI USB is based on the Mediatek implementation but the PHY handling although conceptually similar, is indded different compared to Mediatek due to SSR checks and different port power up.
The SSR driver expose an API to poll the current status of the Serdes port and the USB PHY driver validates it. Refer to the specific commit for additional info.
Consider that there is currently an inconsistency as AN7581 and EN7581 refer to the same thing. This is due to the fact that the SoC born under EcoNet but then was acquired by Airoha.
Changes v2:
- Drop changes for simple-mfd
- Rework PHY node structure to single node
- Drop port-id property in favor of serdes-port and usb2-monitor-clock-sel
- Make the SSR driver probe from the clock driverChristian Marangi (11):
clk: en7523: convert driver to regmap API
clk: en7523: generalize register clocks function
dt-bindings: clock: en7523: add Documentation for Airoha AN7581 SCU
SSR
soc: airoha: add support for configuring SCU SSR Serdes port
clk: en7523: define and register SoC SCU SSR driver for EN7581
soc: airoha: scu-ssr: expose API to read current Serdes Port mode
dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY
phy: move Airoha PCIe PHY driver to dedicated directory
phy: airoha: Add support for Airoha AN7581 USB PHY
usb: host: addARCH_AIROHAin XHCI MTK dependency
arm64: dts: airoha: en7581: add USB nodes.../bindings/clock/airoha,en7523-scu.yaml | 101 +- .../bindings/phy/airoha,an7581-usb-phy.yaml | 83 ++ MAINTAINERS | 21 +- arch/arm64/boot/dts/airoha/en7581.dtsi | 49 + drivers/clk/clk-en7523.c | 340 +++-- drivers/phy/Kconfig | 11 +- drivers/phy/Makefile | 5 +- drivers/phy/airoha/Kconfig | 23 + drivers/phy/airoha/Makefile | 4 + drivers/phy/airoha/phy-airoha-pcie-regs.h | 494 +++++++ drivers/phy/airoha/phy-airoha-pcie.c | 1290 +++++++++++++++++ drivers/phy/airoha/phy-airoha-usb.c | 571 ++++++++ drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/airoha/Kconfig | 18 + drivers/soc/airoha/Makefile | 3 + drivers/soc/airoha/airoha-scu-ssr.c | 271 ++++ drivers/usb/host/Kconfig | 2 +- .../dt-bindings/phy/airoha,an7581-usb-phy.h | 11 + include/dt-bindings/soc/airoha,scu-ssr.h | 11 + include/linux/clk/clk-en7523.h | 10 + include/linux/soc/airoha/airoha-scu-ssr.h | 34 + 22 files changed, 3202 insertions(+), 152 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml create mode 100644 drivers/phy/airoha/Kconfig create mode 100644 drivers/phy/airoha/Makefile create mode 100644 drivers/phy/airoha/phy-airoha-pcie-regs.h create mode 100644 drivers/phy/airoha/phy-airoha-pcie.c create mode 100644 drivers/phy/airoha/phy-airoha-usb.c create mode 100644 drivers/soc/airoha/Kconfig create mode 100644 drivers/soc/airoha/Makefile create mode 100644 drivers/soc/airoha/airoha-scu-ssr.c create mode 100644 include/dt-bindings/phy/airoha,an7581-usb-phy.h create mode 100644 include/dt-bindings/soc/airoha,scu-ssr.h create mode 100644 include/linux/clk/clk-en7523.h create mode 100644 include/linux/soc/airoha/airoha-scu-ssr.h
Quoted 5 lines
--
2.48.1
My bot found new DTB warnings on the .dts files added or changed in this series.
Some warnings may be from an existing SoC .dtsi. Or perhaps the warnings are fixed by another series. Ultimately, it is up to the platform maintainer whether these warnings are acceptable or not. No need to reply unless the platform maintainer has comments.
If you already ran DT checks and didn't see these error(s), then make sure dt-schema is up to date:
pip3 install dtschema --upgrade
New warnings running 'make CHECK_DTBS=y for arch/arm64/boot/dts/airoha/' for [email protected]:
arch/arm64/boot/dts/airoha/en7581-evb.dtb: usb@1fab0000: compatible:0: 'mediatek,mtk-xhci' is not one of ['mediatek,mt2701-xhci', 'mediatek,mt2712-xhci', 'mediatek,mt7622-xhci', 'mediatek,mt7623-xhci', 'mediatek,mt7629-xhci', 'mediatek,mt7986-xhci', 'mediatek,mt7988-xhci', 'mediatek,mt8173-xhci', 'mediatek,mt8183-xhci', 'mediatek,mt8186-xhci', 'mediatek,mt8188-xhci', 'mediatek,mt8192-xhci', 'mediatek,mt8195-xhci', 'mediatek,mt8365-xhci']
from schema $id: http://devicetree.org/schemas/usb/mediatek,mtk-xhci.yaml#arch/arm64/boot/dts/airoha/en7581-evb.dtb: usb@1fab0000: compatible: ['mediatek,mtk-xhci'] is too short
from schema $id: http://devicetree.org/schemas/usb/mediatek,mtk-xhci.yaml#arch/arm64/boot/dts/airoha/en7581-evb.dtb: usb@1fad0000: compatible:0: 'mediatek,mtk-xhci' is not one of ['mediatek,mt2701-xhci', 'mediatek,mt2712-xhci', 'mediatek,mt7622-xhci', 'mediatek,mt7623-xhci', 'mediatek,mt7629-xhci', 'mediatek,mt7986-xhci', 'mediatek,mt7988-xhci', 'mediatek,mt8173-xhci', 'mediatek,mt8183-xhci', 'mediatek,mt8186-xhci', 'mediatek,mt8188-xhci', 'mediatek,mt8192-xhci', 'mediatek,mt8195-xhci', 'mediatek,mt8365-xhci']
from schema $id: http://devicetree.org/schemas/usb/mediatek,mtk-xhci.yaml#arch/arm64/boot/dts/airoha/en7581-evb.dtb: usb@1fad0000: compatible: ['mediatek,mtk-xhci'] is too short
from schema $id: http://devicetree.org/schemas/usb/mediatek,mtk-xhci.yaml#