Message ID | 20181102192616.28291-4-faiz_abbas@ti.com |
---|---|
State | Awaiting Upstream, archived |
Delegated to: | David Miller |
Headers | show |
Series | Add Support for MCAN transceivers in AM65x-evm | expand |
Hi Faiz, Thank you for the patch! Yet something to improve: [auto build test ERROR on net-next/master] [also build test ERROR on v4.19 next-20181102] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Faiz-Abbas/Add-Support-for-MCAN-transceivers-in-AM65x-evm/20181103-103548 config: sh-allmodconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree GCC_VERSION=7.2.0 make.cross ARCH=sh All error/warnings (new ones prefixed by >>): In file included from drivers//phy/phy-of-simple.c:10:0: >> drivers//phy/phy-of-simple.c:76:25: error: 'phy_simple_phy_dt_ids' undeclared here (not in a function); did you mean 'phy_simple_dt_ids'? MODULE_DEVICE_TABLE(of, phy_simple_phy_dt_ids); ^ include/linux/module.h:213:15: note: in definition of macro 'MODULE_DEVICE_TABLE' extern typeof(name) __mod_##type##__##name##_device_table \ ^~~~ >> include/linux/module.h:213:21: error: '__mod_of__phy_simple_phy_dt_ids_device_table' aliased to undefined symbol 'phy_simple_phy_dt_ids' extern typeof(name) __mod_##type##__##name##_device_table \ ^ >> drivers//phy/phy-of-simple.c:76:1: note: in expansion of macro 'MODULE_DEVICE_TABLE' MODULE_DEVICE_TABLE(of, phy_simple_phy_dt_ids); ^~~~~~~~~~~~~~~~~~~ -- In file included from drivers/phy/phy-of-simple.c:10:0: drivers/phy/phy-of-simple.c:76:25: error: 'phy_simple_phy_dt_ids' undeclared here (not in a function); did you mean 'phy_simple_dt_ids'? MODULE_DEVICE_TABLE(of, phy_simple_phy_dt_ids); ^ include/linux/module.h:213:15: note: in definition of macro 'MODULE_DEVICE_TABLE' extern typeof(name) __mod_##type##__##name##_device_table \ ^~~~ >> include/linux/module.h:213:21: error: '__mod_of__phy_simple_phy_dt_ids_device_table' aliased to undefined symbol 'phy_simple_phy_dt_ids' extern typeof(name) __mod_##type##__##name##_device_table \ ^ drivers/phy/phy-of-simple.c:76:1: note: in expansion of macro 'MODULE_DEVICE_TABLE' MODULE_DEVICE_TABLE(of, phy_simple_phy_dt_ids); ^~~~~~~~~~~~~~~~~~~ vim +76 drivers//phy/phy-of-simple.c > 10 #include <linux/module.h> 11 #include <linux/regulator/consumer.h> 12 13 static int phy_simple_power_on(struct phy *phy) 14 { 15 if (phy->pwr) 16 return regulator_enable(phy->pwr); 17 18 return 0; 19 } 20 21 static int phy_simple_power_off(struct phy *phy) 22 { 23 if (phy->pwr) 24 return regulator_disable(phy->pwr); 25 26 return 0; 27 } 28 29 static const struct phy_ops phy_simple_ops = { 30 .power_on = phy_simple_power_on, 31 .power_off = phy_simple_power_off, 32 .owner = THIS_MODULE, 33 }; 34 35 int phy_simple_probe(struct platform_device *pdev) 36 { 37 struct phy_provider *phy_provider; 38 struct device *dev = &pdev->dev; 39 struct regulator *pwr = NULL; 40 struct phy *phy; 41 u32 bus_width = 0; 42 u32 max_bitrate = 0; 43 int ret; 44 45 phy = devm_phy_create(dev, dev->of_node, 46 &phy_simple_ops); 47 48 if (IS_ERR(phy)) { 49 dev_err(dev, "Failed to create phy\n"); 50 return PTR_ERR(phy); 51 } 52 53 device_property_read_u32(dev, "bus-width", &bus_width); 54 phy->attrs.bus_width = bus_width; 55 device_property_read_u32(dev, "max-bitrate", &max_bitrate); 56 phy->attrs.max_bitrate = max_bitrate; 57 58 pwr = devm_regulator_get_optional(dev, "pwr"); 59 if (IS_ERR(pwr)) { 60 ret = PTR_ERR(pwr); 61 dev_err(dev, "Couldn't get regulator. ret=%d\n", ret); 62 return ret; 63 } 64 phy->pwr = pwr; 65 66 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 67 68 return PTR_ERR_OR_ZERO(phy_provider); 69 } 70 71 static const struct of_device_id phy_simple_dt_ids[] = { 72 { .compatible = "simple-phy"}, 73 {} 74 }; 75 > 76 MODULE_DEVICE_TABLE(of, phy_simple_phy_dt_ids); 77 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 60f949e2a684..e66039560da9 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -40,6 +40,13 @@ config PHY_XGENE help This option enables support for APM X-Gene SoC multi-purpose PHY. +config PHY_OF_SIMPLE + tristate "PHY Simple Driver" + select GENERIC_PHY + help + This driver supports simple generic phy implementations which don't + need a dedicated register map. + 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 0301e25d07c1..ffef0fdf2c68 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -4,6 +4,7 @@ # obj-$(CONFIG_GENERIC_PHY) += phy-core.o +obj-$(CONFIG_PHY_OF_SIMPLE) += phy-of-simple.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-of-simple.c b/drivers/phy/phy-of-simple.c new file mode 100644 index 000000000000..0194aae90d3c --- /dev/null +++ b/drivers/phy/phy-of-simple.c @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * phy-of-simple.c - phy driver for simple implementations + * + * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com + * + */ +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/module.h> +#include <linux/regulator/consumer.h> + +static int phy_simple_power_on(struct phy *phy) +{ + if (phy->pwr) + return regulator_enable(phy->pwr); + + return 0; +} + +static int phy_simple_power_off(struct phy *phy) +{ + if (phy->pwr) + return regulator_disable(phy->pwr); + + return 0; +} + +static const struct phy_ops phy_simple_ops = { + .power_on = phy_simple_power_on, + .power_off = phy_simple_power_off, + .owner = THIS_MODULE, +}; + +int phy_simple_probe(struct platform_device *pdev) +{ + struct phy_provider *phy_provider; + struct device *dev = &pdev->dev; + struct regulator *pwr = NULL; + struct phy *phy; + u32 bus_width = 0; + u32 max_bitrate = 0; + int ret; + + phy = devm_phy_create(dev, dev->of_node, + &phy_simple_ops); + + if (IS_ERR(phy)) { + dev_err(dev, "Failed to create phy\n"); + return PTR_ERR(phy); + } + + device_property_read_u32(dev, "bus-width", &bus_width); + phy->attrs.bus_width = bus_width; + device_property_read_u32(dev, "max-bitrate", &max_bitrate); + phy->attrs.max_bitrate = max_bitrate; + + pwr = devm_regulator_get_optional(dev, "pwr"); + if (IS_ERR(pwr)) { + ret = PTR_ERR(pwr); + dev_err(dev, "Couldn't get regulator. ret=%d\n", ret); + return ret; + } + phy->pwr = pwr; + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + + return PTR_ERR_OR_ZERO(phy_provider); +} + +static const struct of_device_id phy_simple_dt_ids[] = { + { .compatible = "simple-phy"}, + {} +}; + +MODULE_DEVICE_TABLE(of, phy_simple_phy_dt_ids); + +static struct platform_driver phy_simple_driver = { + .probe = phy_simple_probe, + .driver = { + .name = "phy-of-simple", + .of_match_table = phy_simple_dt_ids, + }, +}; + +module_platform_driver(phy_simple_driver); + +MODULE_AUTHOR("Faiz Abbas <faiz_abbas@ti.com>"); +MODULE_DESCRIPTION("Simple PHY driver"); +MODULE_LICENSE("GPL v2");
A good number of phy implementations don't have a dedicated register map and only do simple clock or regulator configurations. Add support for a generic driver which just does such simple configurations. The driver optionally gets all the generic phy attributes and also the pwr regulator node. It also includes a generic implementation of phy_power_on() and phy_power_off(). Signed-off-by: Faiz Abbas <faiz_abbas@ti.com> --- drivers/phy/Kconfig | 7 +++ drivers/phy/Makefile | 1 + drivers/phy/phy-of-simple.c | 90 +++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 drivers/phy/phy-of-simple.c