From: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> To: linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, "Benoît Cousson" <bcousson-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "Lokesh Vutla" <lokeshvutla-l0cyMroinI0@public.gmane.org>, "Nishanth Menon" <nm-l0cyMroinI0@public.gmane.org>, "Paul Walmsley" <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>, "Tero Kristo" <t-kristo-l0cyMroinI0@public.gmane.org> Subject: [PATCH 06/10] ARM: OMAP2+: Populate legacy resources for dma and smartreflex Date: Wed, 20 Sep 2017 15:46:17 -0700 [thread overview] Message-ID: <20170920224621.16236-7-tony@atomide.com> (raw) In-Reply-To: <20170920224621.16236-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> We can populate the legacy resources needed by dma and smartreflex from device tree in omap_device_build(). There should be no need to do this for other devices, and eventually these two remaining users will be gone too. The legacy dma will be dropped when the remaining users have been converted to use the dmaengine driver, and smartreflex can now become just a regular device driver with a few pdata callbacks. This is needed in order to remove remaining device dma, irq and io resources from the interconnect code. And while at it, let's simplify things by removing otherwise unused omap_device_build_ss() as we will never call it for more than one hwmod. Cc: "Benoît Cousson" <bcousson-rdvid1DuHRBWk0Htik3J/w@public.gmane.org> Cc: Lokesh Vutla <lokeshvutla-l0cyMroinI0@public.gmane.org> Cc: Nishanth Menon <nm-l0cyMroinI0@public.gmane.org> Cc: Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org> Cc: Tero Kristo <t-kristo-l0cyMroinI0@public.gmane.org> Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> --- arch/arm/mach-omap2/omap_device.c | 137 +++++++++++++++++++++++++++++--------- arch/arm/mach-omap2/omap_device.h | 4 -- 2 files changed, 106 insertions(+), 35 deletions(-) diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c --- a/arch/arm/mach-omap2/omap_device.c +++ b/arch/arm/mach-omap2/omap_device.c @@ -35,6 +35,8 @@ #include <linux/pm_domain.h> #include <linux/pm_runtime.h> #include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> #include <linux/notifier.h> #include "common.h" @@ -521,6 +523,91 @@ void omap_device_delete(struct omap_device *od) kfree(od); } +/** + * omap_device_copy_resources - Add legacy IO and IRQ resources + * @oh: interconnect target module + * @pdev: platform device to copy resources to + * + * We still have legacy DMA and smartreflex needing resources. + * Let's populate what they need until we can eventually just + * remove this function. Note that there should be no need to + * call this from omap_device_build_from_dt(), nor should there + * be any need to call it for other devices. + */ +static int +omap_device_copy_resources(struct omap_hwmod *oh, + struct platform_device *pdev) +{ + struct device_node *np, *child; + struct property *prop; + struct resource *res; + const char *name; + int error, irq = 0; + + if (!oh || !oh->od || !oh->od->pdev) { + error = -EINVAL; + goto error; + } + + np = oh->od->pdev->dev.of_node; + if (!np) { + error = -ENODEV; + goto error; + } + + res = kzalloc(sizeof(*res) * 2, GFP_KERNEL); + if (!res) + return -ENOMEM; + + /* Do we have a dts range for the interconnect target module? */ + error = omap_hwmod_parse_module_range(oh, np, res); + + /* No ranges, rely on device reg entry */ + if (error) + error = of_address_to_resource(np, 0, res); + if (error) + goto free; + + /* SmartReflex needs first IO resource name to be "mpu" */ + res[0].name = "mpu"; + + /* + * We may have a new stil "ti,sysc" interconnect target with a + * dts child with the interrupt. If so use the first child's + * first interrupt for "ti-hwmods" legacy support. + */ + of_property_for_each_string(np, "compatible", prop, name) + if (!strncmp("ti,sysc-", name, 8)) + break; + + child = of_get_next_available_child(np, NULL); + + if (name) + irq = irq_of_parse_and_map(child, 0); + if (!irq) + irq = irq_of_parse_and_map(np, 0); + if (!irq) + goto free; + + /* Legacy DMA code needs interrupt name to be "0" */ + res[1].start = irq; + res[1].end = irq; + res[1].flags = IORESOURCE_IRQ; + res[1].name = "0"; + + error = platform_device_add_resources(pdev, res, 2); + +free: + kfree(res); + +error: + WARN(error, "%s: %s device %s failed: %i\n", + __func__, oh->name, dev_name(&pdev->dev), + error); + + return error; +} + /** * omap_device_build - build and register an omap_device with one omap_hwmod * @pdev_name: name of the platform_device driver to use @@ -539,46 +626,25 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id, struct omap_hwmod *oh, void *pdata, int pdata_len) -{ - struct omap_hwmod *ohs[] = { oh }; - - if (!oh) - return ERR_PTR(-EINVAL); - - return omap_device_build_ss(pdev_name, pdev_id, ohs, 1, pdata, - pdata_len); -} - -/** - * omap_device_build_ss - build and register an omap_device with multiple hwmods - * @pdev_name: name of the platform_device driver to use - * @pdev_id: this platform_device's connection ID - * @oh: ptr to the single omap_hwmod that backs this omap_device - * @pdata: platform_data ptr to associate with the platform_device - * @pdata_len: amount of memory pointed to by @pdata - * - * Convenience function for building and registering an omap_device - * subsystem record. Subsystem records consist of multiple - * omap_hwmods. This function in turn builds and registers a - * platform_device record. Returns an ERR_PTR() on error, or passes - * along the return value of omap_device_register(). - */ -struct platform_device __init *omap_device_build_ss(const char *pdev_name, - int pdev_id, - struct omap_hwmod **ohs, - int oh_cnt, void *pdata, - int pdata_len) { int ret = -ENOMEM; struct platform_device *pdev; struct omap_device *od; - if (!ohs || oh_cnt == 0 || !pdev_name) + if (!oh || !pdev_name) return ERR_PTR(-EINVAL); if (!pdata && pdata_len > 0) return ERR_PTR(-EINVAL); + if (strncmp(oh->name, "smartreflex", 11) && + strncmp(oh->name, "dma", 3)) { + pr_warn("%s need to update %s to probe with dt\na", + __func__, pdev_name); + ret = -ENODEV; + goto odbs_exit; + } + pdev = platform_device_alloc(pdev_name, pdev_id); if (!pdev) { ret = -ENOMEM; @@ -591,7 +657,16 @@ struct platform_device __init *omap_device_build_ss(const char *pdev_name, else dev_set_name(&pdev->dev, "%s", pdev->name); - od = omap_device_alloc(pdev, ohs, oh_cnt); + /* + * Must be called before omap_device_alloc() as oh->od + * only contains the currently registered omap_device + * and will get overwritten by omap_device_alloc(). + */ + ret = omap_device_copy_resources(oh, pdev); + if (ret) + goto odbs_exit1; + + od = omap_device_alloc(pdev, &oh, 1); if (IS_ERR(od)) goto odbs_exit1; diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h --- a/arch/arm/mach-omap2/omap_device.h +++ b/arch/arm/mach-omap2/omap_device.h @@ -75,10 +75,6 @@ struct platform_device *omap_device_build(const char *pdev_name, int pdev_id, struct omap_hwmod *oh, void *pdata, int pdata_len); -struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id, - struct omap_hwmod **oh, int oh_cnt, - void *pdata, int pdata_len); - struct omap_device *omap_device_alloc(struct platform_device *pdev, struct omap_hwmod **ohs, int oh_cnt); void omap_device_delete(struct omap_device *od); -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: tony@atomide.com (Tony Lindgren) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 06/10] ARM: OMAP2+: Populate legacy resources for dma and smartreflex Date: Wed, 20 Sep 2017 15:46:17 -0700 [thread overview] Message-ID: <20170920224621.16236-7-tony@atomide.com> (raw) In-Reply-To: <20170920224621.16236-1-tony@atomide.com> We can populate the legacy resources needed by dma and smartreflex from device tree in omap_device_build(). There should be no need to do this for other devices, and eventually these two remaining users will be gone too. The legacy dma will be dropped when the remaining users have been converted to use the dmaengine driver, and smartreflex can now become just a regular device driver with a few pdata callbacks. This is needed in order to remove remaining device dma, irq and io resources from the interconnect code. And while at it, let's simplify things by removing otherwise unused omap_device_build_ss() as we will never call it for more than one hwmod. Cc: "Beno?t Cousson" <bcousson@baylibre.com> Cc: Lokesh Vutla <lokeshvutla@ti.com> Cc: Nishanth Menon <nm@ti.com> Cc: Paul Walmsley <paul@pwsan.com> Cc: Tero Kristo <t-kristo@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com> --- arch/arm/mach-omap2/omap_device.c | 137 +++++++++++++++++++++++++++++--------- arch/arm/mach-omap2/omap_device.h | 4 -- 2 files changed, 106 insertions(+), 35 deletions(-) diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c --- a/arch/arm/mach-omap2/omap_device.c +++ b/arch/arm/mach-omap2/omap_device.c @@ -35,6 +35,8 @@ #include <linux/pm_domain.h> #include <linux/pm_runtime.h> #include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> #include <linux/notifier.h> #include "common.h" @@ -521,6 +523,91 @@ void omap_device_delete(struct omap_device *od) kfree(od); } +/** + * omap_device_copy_resources - Add legacy IO and IRQ resources + * @oh: interconnect target module + * @pdev: platform device to copy resources to + * + * We still have legacy DMA and smartreflex needing resources. + * Let's populate what they need until we can eventually just + * remove this function. Note that there should be no need to + * call this from omap_device_build_from_dt(), nor should there + * be any need to call it for other devices. + */ +static int +omap_device_copy_resources(struct omap_hwmod *oh, + struct platform_device *pdev) +{ + struct device_node *np, *child; + struct property *prop; + struct resource *res; + const char *name; + int error, irq = 0; + + if (!oh || !oh->od || !oh->od->pdev) { + error = -EINVAL; + goto error; + } + + np = oh->od->pdev->dev.of_node; + if (!np) { + error = -ENODEV; + goto error; + } + + res = kzalloc(sizeof(*res) * 2, GFP_KERNEL); + if (!res) + return -ENOMEM; + + /* Do we have a dts range for the interconnect target module? */ + error = omap_hwmod_parse_module_range(oh, np, res); + + /* No ranges, rely on device reg entry */ + if (error) + error = of_address_to_resource(np, 0, res); + if (error) + goto free; + + /* SmartReflex needs first IO resource name to be "mpu" */ + res[0].name = "mpu"; + + /* + * We may have a new stil "ti,sysc" interconnect target with a + * dts child with the interrupt. If so use the first child's + * first interrupt for "ti-hwmods" legacy support. + */ + of_property_for_each_string(np, "compatible", prop, name) + if (!strncmp("ti,sysc-", name, 8)) + break; + + child = of_get_next_available_child(np, NULL); + + if (name) + irq = irq_of_parse_and_map(child, 0); + if (!irq) + irq = irq_of_parse_and_map(np, 0); + if (!irq) + goto free; + + /* Legacy DMA code needs interrupt name to be "0" */ + res[1].start = irq; + res[1].end = irq; + res[1].flags = IORESOURCE_IRQ; + res[1].name = "0"; + + error = platform_device_add_resources(pdev, res, 2); + +free: + kfree(res); + +error: + WARN(error, "%s: %s device %s failed: %i\n", + __func__, oh->name, dev_name(&pdev->dev), + error); + + return error; +} + /** * omap_device_build - build and register an omap_device with one omap_hwmod * @pdev_name: name of the platform_device driver to use @@ -539,46 +626,25 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id, struct omap_hwmod *oh, void *pdata, int pdata_len) -{ - struct omap_hwmod *ohs[] = { oh }; - - if (!oh) - return ERR_PTR(-EINVAL); - - return omap_device_build_ss(pdev_name, pdev_id, ohs, 1, pdata, - pdata_len); -} - -/** - * omap_device_build_ss - build and register an omap_device with multiple hwmods - * @pdev_name: name of the platform_device driver to use - * @pdev_id: this platform_device's connection ID - * @oh: ptr to the single omap_hwmod that backs this omap_device - * @pdata: platform_data ptr to associate with the platform_device - * @pdata_len: amount of memory pointed to by @pdata - * - * Convenience function for building and registering an omap_device - * subsystem record. Subsystem records consist of multiple - * omap_hwmods. This function in turn builds and registers a - * platform_device record. Returns an ERR_PTR() on error, or passes - * along the return value of omap_device_register(). - */ -struct platform_device __init *omap_device_build_ss(const char *pdev_name, - int pdev_id, - struct omap_hwmod **ohs, - int oh_cnt, void *pdata, - int pdata_len) { int ret = -ENOMEM; struct platform_device *pdev; struct omap_device *od; - if (!ohs || oh_cnt == 0 || !pdev_name) + if (!oh || !pdev_name) return ERR_PTR(-EINVAL); if (!pdata && pdata_len > 0) return ERR_PTR(-EINVAL); + if (strncmp(oh->name, "smartreflex", 11) && + strncmp(oh->name, "dma", 3)) { + pr_warn("%s need to update %s to probe with dt\na", + __func__, pdev_name); + ret = -ENODEV; + goto odbs_exit; + } + pdev = platform_device_alloc(pdev_name, pdev_id); if (!pdev) { ret = -ENOMEM; @@ -591,7 +657,16 @@ struct platform_device __init *omap_device_build_ss(const char *pdev_name, else dev_set_name(&pdev->dev, "%s", pdev->name); - od = omap_device_alloc(pdev, ohs, oh_cnt); + /* + * Must be called before omap_device_alloc() as oh->od + * only contains the currently registered omap_device + * and will get overwritten by omap_device_alloc(). + */ + ret = omap_device_copy_resources(oh, pdev); + if (ret) + goto odbs_exit1; + + od = omap_device_alloc(pdev, &oh, 1); if (IS_ERR(od)) goto odbs_exit1; diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h --- a/arch/arm/mach-omap2/omap_device.h +++ b/arch/arm/mach-omap2/omap_device.h @@ -75,10 +75,6 @@ struct platform_device *omap_device_build(const char *pdev_name, int pdev_id, struct omap_hwmod *oh, void *pdata, int pdata_len); -struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id, - struct omap_hwmod **oh, int oh_cnt, - void *pdata, int pdata_len); - struct omap_device *omap_device_alloc(struct platform_device *pdev, struct omap_hwmod **ohs, int oh_cnt); void omap_device_delete(struct omap_device *od); -- 2.14.1
next prev parent reply other threads:[~2017-09-20 22:46 UTC|newest] Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-09-20 22:46 [PATCHv3 00/10] Fix remaining issues to drop more omap platform data Tony Lindgren 2017-09-20 22:46 ` Tony Lindgren 2017-09-20 22:46 ` [PATCH 02/10] ARM: dts: omap4: add fck under timer1 Tony Lindgren 2017-09-20 22:46 ` Tony Lindgren 2017-09-20 22:46 ` [PATCH 03/10] ARM: dts: omap4: add bus functionality to base PRCM nodes Tony Lindgren 2017-09-20 22:46 ` Tony Lindgren [not found] ` <20170920224621.16236-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> 2017-09-20 22:46 ` [PATCH 01/10] dt-bindings: bus: Minimal TI sysc interconnect target module binding Tony Lindgren 2017-09-20 22:46 ` Tony Lindgren [not found] ` <20170920224621.16236-2-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> 2017-09-25 6:35 ` Matthijs van Duin 2017-09-25 6:35 ` Matthijs van Duin [not found] ` <20170925063545.nn3gr5drea6o2g6m-2pNSKKP3PSK44ywRPIzf9A@public.gmane.org> 2017-09-25 14:25 ` Tony Lindgren 2017-09-25 14:25 ` Tony Lindgren [not found] ` <20170925142520.GE4394-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> 2017-09-25 17:21 ` Matthijs van Duin 2017-09-25 17:21 ` Matthijs van Duin [not found] ` <20170925172120.xu6k3leg4ac6mjya-2pNSKKP3PSK44ywRPIzf9A@public.gmane.org> 2017-09-25 17:44 ` Tony Lindgren 2017-09-25 17:44 ` Tony Lindgren [not found] ` <20170925174413.GH4394-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> 2017-09-27 9:56 ` Matthijs van Duin 2017-09-27 9:56 ` Matthijs van Duin [not found] ` <20170927095646.fi4l7jbbvrubfe25-2pNSKKP3PSK44ywRPIzf9A@public.gmane.org> 2017-09-29 17:51 ` Tony Lindgren 2017-09-29 17:51 ` Tony Lindgren 2017-09-25 7:03 ` Matthijs van Duin 2017-09-25 7:03 ` Matthijs van Duin [not found] ` <20170925070345.2uraikhswru77rm4-2pNSKKP3PSK44ywRPIzf9A@public.gmane.org> 2017-09-25 14:37 ` Tony Lindgren 2017-09-25 14:37 ` Tony Lindgren 2017-09-20 22:46 ` [PATCH 04/10] ARM: dts: omap4: add clkctrl nodes Tony Lindgren 2017-09-20 22:46 ` Tony Lindgren 2017-09-20 22:46 ` [PATCH 05/10] ARM: OMAP2+: Parse module IO range from dts for legacy "ti,hwmods" support Tony Lindgren 2017-09-20 22:46 ` [PATCH 05/10] ARM: OMAP2+: Parse module IO range from dts for legacy "ti, hwmods" support Tony Lindgren 2017-09-20 22:46 ` Tony Lindgren [this message] 2017-09-20 22:46 ` [PATCH 06/10] ARM: OMAP2+: Populate legacy resources for dma and smartreflex Tony Lindgren 2017-09-20 22:46 ` [PATCH 08/10] ARM: dts: Add nodes for missing omap4 interconnect target modules Tony Lindgren 2017-09-20 22:46 ` Tony Lindgren [not found] ` <20170920224621.16236-9-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> 2017-09-21 2:56 ` Matthijs van Duin 2017-09-21 2:56 ` Matthijs van Duin [not found] ` <20170921025656.omeoippus7b4mmig-2pNSKKP3PSK44ywRPIzf9A@public.gmane.org> 2017-09-21 14:27 ` Tony Lindgren 2017-09-21 14:27 ` Tony Lindgren 2017-09-20 22:46 ` [PATCH 09/10] ARM: dts: Configure SmartReflex only to idle the interconnect target module Tony Lindgren 2017-09-20 22:46 ` Tony Lindgren 2017-09-20 22:46 ` [PATCH 10/10] ARM: dts: Use ti-sysc module driver for omap4 musb Tony Lindgren 2017-09-20 22:46 ` Tony Lindgren 2017-09-20 22:46 ` [PATCH 07/10] bus: ti-sysc: Add minimal TI sysc interconnect target driver Tony Lindgren 2017-09-20 22:46 ` Tony Lindgren
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20170920224621.16236-7-tony@atomide.com \ --to=tony-4v6ys6ai5vpbdgjk7y7tuq@public.gmane.org \ --cc=bcousson-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \ --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \ --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=lokeshvutla-l0cyMroinI0@public.gmane.org \ --cc=nm-l0cyMroinI0@public.gmane.org \ --cc=paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org \ --cc=t-kristo-l0cyMroinI0@public.gmane.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.