* [PATCH v4 0/4] reset: APIs to manage a list of resets @ 2017-05-22 11:23 Vivek Gautam [not found] ` <1495452207-6129-1-git-send-email-vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Vivek Gautam @ 2017-05-22 11:23 UTC (permalink / raw) To: p.zabel, linux-kernel Cc: linux-tegra, linux-usb, jonathanh, balbi, gregkh, linux-arm-msm, Vivek Gautam Set of patches to support getting and de/asserting a list (array) of reset controllers available with the device. This series also contains reset controls patches for dwc3-of-simple and tegra pmc drivers. A small patch is added in this series to correctly re-order the resource handling in dwc3_of_simple_remove(). The series is tested on torvald's master branch the device tree patches to enable usb on db820c. Changes since v3: - Squashed of_reset_control_get_count() patch in the second patch that adds the reset control array APIs. - The error path after getting count through of_reset_control_get_count() now returns NULL pointer in case when 'optional' flag is true. - Added code in reset_control_array_assert() to deassert the already asserted resets in the error case. - Using of_reset_control_array_get_optional_exclusive() in dwc3 patch to request the reset control array. - Added a patch to fix the order in which resources are handled in dwc3_of_simple_remove() path. - Added tegra_powergate->reset to take care of single reset control passed from the client drivers. Changes since v2: - Addressed comments to make APIs inline with gpiod API. - Moved number of reset controls in 'struct reset_control_array' so that the footprint is reduced. - of_reset_control_array_get() and devm_reset_control_array_get() now return pointer to the newly created reset control array. - Added comments to mention that the reset control array APIs don't guarantee any particular order when handling the reset controls. - Dropped 'name' from reset_control_array' since the interface is meant for a bunch of anonymous resets that can all be asserted or deasserted in arbitrary order. - Fixed returns for APIs reported by kbuild. - Fixed 'for' clause guards reported by kbuild. Changes since v1: - Addressed comment for error handling in of_reset_control_get_count() - Added patch to manage reset controller array. - Rebased dwc3-of-simple changes based on the new set of APIs for reset control array. - Added a patch for soc/tegra/pmc driver to use the new set of reset control array APIs. Vivek Gautam (4): usb: dwc3: of-simple: Re-order resource handling in remove reset: Add APIs to manage array of resets usb: dwc3: of-simple: Add support to get resets for the device soc/tegra: pmc: Use the new reset APIs to manage reset controllers drivers/reset/core.c | 204 ++++++++++++++++++++++++++++++++++++++ drivers/soc/tegra/pmc.c | 91 ++++++----------- drivers/usb/dwc3/dwc3-of-simple.c | 29 +++++- include/linux/reset.h | 93 +++++++++++++++++ 4 files changed, 354 insertions(+), 63 deletions(-) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <1495452207-6129-1-git-send-email-vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>]
* [PATCH v4 1/4] usb: dwc3: of-simple: Re-order resource handling in remove 2017-05-22 11:23 [PATCH v4 0/4] reset: APIs to manage a list of resets Vivek Gautam @ 2017-05-22 11:23 ` Vivek Gautam 2017-05-22 11:23 ` [PATCH v4 3/4] usb: dwc3: of-simple: Add support to get resets for the device Vivek Gautam 2017-05-22 11:23 ` [PATCH v4 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers Vivek Gautam 2 siblings, 0 replies; 13+ messages in thread From: Vivek Gautam @ 2017-05-22 11:23 UTC (permalink / raw) To: p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA, jonathanh-DDmLM1+adcrQT0dZR+AlfA, balbi-DgEjT+Ai2ygdnm+yROfE0A, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, linux-arm-msm-u79uwXL29TY76Z2rM5mHXA, Vivek Gautam Move clock handling after of_platform_depopulate to achieve a sequence that is reverse of the probe sequence. Cc: Felipe Balbi <balbi-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Signed-off-by: Vivek Gautam <vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> --- - new patch in this series. drivers/usb/dwc3/dwc3-of-simple.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index fe414e7a9c78..a9bac09d3750 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c @@ -123,13 +123,13 @@ static int dwc3_of_simple_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; int i; + of_platform_depopulate(dev); + for (i = 0; i < simple->num_clocks; i++) { clk_disable_unprepare(simple->clks[i]); clk_put(simple->clks[i]); } - of_platform_depopulate(dev); ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v4 1/4] usb: dwc3: of-simple: Re-order resource handling in remove @ 2017-05-22 11:23 ` Vivek Gautam 0 siblings, 0 replies; 13+ messages in thread From: Vivek Gautam @ 2017-05-22 11:23 UTC (permalink / raw) To: p.zabel, linux-kernel Cc: linux-tegra, linux-usb, jonathanh, balbi, gregkh, linux-arm-msm, Vivek Gautam Move clock handling after of_platform_depopulate to achieve a sequence that is reverse of the probe sequence. Cc: Felipe Balbi <balbi@kernel.org> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> --- - new patch in this series. drivers/usb/dwc3/dwc3-of-simple.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index fe414e7a9c78..a9bac09d3750 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c @@ -123,13 +123,13 @@ static int dwc3_of_simple_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; int i; + of_platform_depopulate(dev); + for (i = 0; i < simple->num_clocks; i++) { clk_disable_unprepare(simple->clks[i]); clk_put(simple->clks[i]); } - of_platform_depopulate(dev); - pm_runtime_put_sync(dev); pm_runtime_disable(dev); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v4 2/4] reset: Add APIs to manage array of resets 2017-05-22 11:23 [PATCH v4 0/4] reset: APIs to manage a list of resets Vivek Gautam @ 2017-05-22 11:23 ` Vivek Gautam 2017-05-22 11:23 ` [PATCH v4 3/4] usb: dwc3: of-simple: Add support to get resets for the device Vivek Gautam 2017-05-22 11:23 ` [PATCH v4 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers Vivek Gautam 2 siblings, 0 replies; 13+ messages in thread From: Vivek Gautam @ 2017-05-22 11:23 UTC (permalink / raw) To: p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA, jonathanh-DDmLM1+adcrQT0dZR+AlfA, balbi-DgEjT+Ai2ygdnm+yROfE0A, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, linux-arm-msm-u79uwXL29TY76Z2rM5mHXA, Vivek Gautam Many devices may want to request a bunch of resets and control them. So it's better to manage them as an array. Add APIs to _get(), _assert(), and _deassert() an array of reset_control. Note that, these APIs don't guarantee that the reset lines managed in the array are handled in any particular order. Cc: Felipe Balbi <balbi-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Cc: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> Cc: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> Signed-off-by: Vivek Gautam <vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> --- drivers/reset/core.c | 204 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/reset.h | 93 +++++++++++++++++++++++ 2 files changed, 297 insertions(+) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index cd739d2fa160..dfb782f862e0 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -465,3 +465,207 @@ int device_reset(struct device *dev) return ret; } EXPORT_SYMBOL_GPL(device_reset); + +/** + * APIs to manage an array of reset controls. + */ +/** + * of_reset_control_get_count - Count number of resets available with a device + * + * @node: device node that contains 'resets'. + * + * Returns positive reset count on success, or error number on failure and + * on count being zero. + */ +static int of_reset_control_get_count(struct device_node *node) +{ + int count; + + if (!node) + return -EINVAL; + + count = of_count_phandle_with_args(node, "resets", "#reset-cells"); + if (count == 0) + count = -ENOENT; + + return count; +} + +/** + * reset_control_array_assert: assert a list of resets + * + * @resets: reset control array holding info about the list of resets + * + * This API doesn't guarantee that the reset lines controlled by + * the reset array are asserted in any particular order. + * + * Returns 0 on success or error number on failure. + */ +int reset_control_array_assert(struct reset_control_array *resets) +{ + int ret, i; + + if (!resets) + return 0; + + if (IS_ERR(resets)) + return -EINVAL; + + for (i = 0; i < resets->num_rstcs; i++) { + ret = reset_control_assert(resets->rstc[i]); + if (ret) + goto err; + } + + return 0; + +err: + while (i--) + reset_control_deassert(resets->rstc[i]); + return ret; +} +EXPORT_SYMBOL_GPL(reset_control_array_assert); + +/** + * reset_control_array_deassert: deassert a list of resets + * + * @resets: reset control array holding info about the list of resets + * + * This API doesn't guarantee that the reset lines controlled by + * the reset array are deasserted in any particular order. + * + * Returns 0 on success or error number on failure. + */ +int reset_control_array_deassert(struct reset_control_array *resets) +{ + int ret, i; + + if (!resets) + return 0; + + if (IS_ERR(resets)) + return -EINVAL; + + for (i = 0; i < resets->num_rstcs; i++) { + ret = reset_control_deassert(resets->rstc[i]); + if (ret) + goto err; + } + + return 0; + +err: + while (i--) + reset_control_assert(resets->rstc[i]); + return ret; +} +EXPORT_SYMBOL_GPL(reset_control_array_deassert); + +static void devm_reset_control_array_release(struct device *dev, void *res) +{ + struct reset_control_array *resets = res; + + reset_control_array_put(resets); +} + +/** + * of_reset_control_array_get - Get a list of reset controls using + * device node. + * + * @np: device node for the device that requests the reset controls array + * @shared: whether reset controls are shared or not + * @optional: whether it is optional to get the reset controls + * + * Returns pointer to allocated reset_control_array on success or + * error on failure + */ +struct reset_control_array * +of_reset_control_array_get(struct device_node *np, bool shared, bool optional) +{ + struct reset_control_array *resets; + struct reset_control *rstc; + int num, i; + void *err; + + num = of_reset_control_get_count(np); + if (num < 0) + return optional ? NULL : ERR_PTR(num); + + resets = kzalloc(sizeof(*resets) + sizeof(resets->rstc[0]) * num, + GFP_KERNEL); + if (!resets) + return ERR_PTR(-ENOMEM); + + for (i = 0; i < num; i++) { + rstc = __of_reset_control_get(np, NULL, i, shared, optional); + if (IS_ERR(rstc)) { + err = ERR_CAST(rstc); + goto err_rst; + } + resets->rstc[i] = rstc; + } + resets->num_rstcs = num; + + return resets; + +err_rst: + while (--i >= 0) + reset_control_put(resets->rstc[i]); + + kfree(resets); + + return err; +} +EXPORT_SYMBOL_GPL(of_reset_control_array_get); + +/** + * devm_reset_control_array_get - Resource managed reset control array get + * + * @dev: device that requests the list of reset controls + * @shared: whether reset controls are shared or not + * @optional: whether it is optional to get the reset controls + * + * The reset control array APIs are intended for a list of resets + * that just have to be asserted or deasserted, without any + * requirements on the order. + * + * Returns pointer to allocated reset_control_array on success or + * error on failure + */ +struct reset_control_array * +devm_reset_control_array_get(struct device *dev, bool shared, bool optional) +{ + struct reset_control_array **devres; + struct reset_control_array *resets; + + devres = devres_alloc(devm_reset_control_array_release, + sizeof(*devres), GFP_KERNEL); + if (!devres) + return ERR_PTR(-ENOMEM); + + resets = of_reset_control_array_get(dev->of_node, shared, optional); + if (IS_ERR(resets)) { + devres_free(resets); + return resets; + } + + *devres = resets; + devres_add(dev, devres); + + return resets; +} +EXPORT_SYMBOL_GPL(devm_reset_control_array_get); + +void reset_control_array_put(struct reset_control_array *resets) +{ + int i; + + if (IS_ERR_OR_NULL(resets)) + return; + + for (i = 0; i < resets->num_rstcs; i++) + reset_control_put(resets->rstc[i]); + + kfree(resets); +} +EXPORT_SYMBOL_GPL(reset_control_array_put); diff --git a/include/linux/reset.h b/include/linux/reset.h index 13d8681210d5..df75fe50f765 100644 --- a/include/linux/reset.h +++ b/include/linux/reset.h @@ -5,6 +5,11 @@ struct reset_control; +struct reset_control_array { + unsigned int num_rstcs; + struct reset_control *rstc[]; +}; + #ifdef CONFIG_RESET_CONTROLLER int reset_control_reset(struct reset_control *rstc); @@ -25,6 +30,14 @@ struct reset_control *__devm_reset_control_get(struct device *dev, int __must_check device_reset(struct device *dev); +int reset_control_array_assert(struct reset_control_array *resets); +int reset_control_array_deassert(struct reset_control_array *resets); +struct reset_control_array *devm_reset_control_array_get(struct device *dev, + bool shared, bool optional); +struct reset_control_array *of_reset_control_array_get(struct device_node *np, + bool shared, bool optional); +void reset_control_array_put(struct reset_control_array *resets); + static inline int device_reset_optional(struct device *dev) { return device_reset(dev); @@ -89,6 +102,35 @@ static inline struct reset_control *__devm_reset_control_get( return optional ? NULL : ERR_PTR(-ENOTSUPP); } +static inline +int reset_control_array_assert(struct reset_control_array *resets) +{ + return 0; +} + +static inline +int reset_control_array_deassert(struct reset_control_array *resets) +{ + return 0; +} + +static inline struct reset_control_array * +devm_reset_control_array_get(struct device *dev, bool shared, bool optional) +{ + return optional ? NULL : ERR_PTR(-ENOTSUPP); +} + +static inline struct reset_control_array * +of_reset_control_array_get(struct device_node *np, bool shared, bool optional) +{ + return optional ? NULL : ERR_PTR(-ENOTSUPP); +} + +static inline +void reset_control_array_put(struct reset_control_array *resets) +{ +} + #endif /* CONFIG_RESET_CONTROLLER */ /** @@ -374,4 +416,55 @@ static inline struct reset_control *devm_reset_control_get_by_index( { return devm_reset_control_get_exclusive_by_index(dev, index); } + +/* + * APIs to manage a list of reset controllers + */ +static inline struct reset_control_array * +devm_reset_control_array_get_exclusive(struct device *dev) +{ + return devm_reset_control_array_get(dev, false, false); +} + +static inline struct reset_control_array * +devm_reset_control_array_get_shared(struct device *dev) +{ + return devm_reset_control_array_get(dev, true, false); +} + +static inline struct reset_control_array * +devm_reset_control_array_get_optional_exclusive(struct device *dev) +{ + return devm_reset_control_array_get(dev, false, true); +} + +static inline struct reset_control_array * +devm_reset_control_array_get_optional_shared(struct device *dev) +{ + return devm_reset_control_array_get(dev, true, true); +} + +static inline struct reset_control_array * +of_reset_control_array_get_exclusive(struct device_node *node) +{ + return of_reset_control_array_get(node, false, false); +} + +static inline struct reset_control_array * +of_reset_control_array_get_shared(struct device_node *node) +{ + return of_reset_control_array_get(node, true, false); +} + +static inline struct reset_control_array * +of_reset_control_array_get_optional_exclusive(struct device_node *node) +{ + return of_reset_control_array_get(node, false, true); +} + +static inline struct reset_control_array * +of_reset_control_array_get_optional_shared(struct device_node *node) +{ + return of_reset_control_array_get(node, true, true); +} #endif -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v4 2/4] reset: Add APIs to manage array of resets @ 2017-05-22 11:23 ` Vivek Gautam 0 siblings, 0 replies; 13+ messages in thread From: Vivek Gautam @ 2017-05-22 11:23 UTC (permalink / raw) To: p.zabel, linux-kernel Cc: linux-tegra, linux-usb, jonathanh, balbi, gregkh, linux-arm-msm, Vivek Gautam Many devices may want to request a bunch of resets and control them. So it's better to manage them as an array. Add APIs to _get(), _assert(), and _deassert() an array of reset_control. Note that, these APIs don't guarantee that the reset lines managed in the array are handled in any particular order. Cc: Felipe Balbi <balbi@kernel.org> Cc: Jon Hunter <jonathanh@nvidia.com> Cc: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> --- drivers/reset/core.c | 204 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/reset.h | 93 +++++++++++++++++++++++ 2 files changed, 297 insertions(+) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index cd739d2fa160..dfb782f862e0 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -465,3 +465,207 @@ int device_reset(struct device *dev) return ret; } EXPORT_SYMBOL_GPL(device_reset); + +/** + * APIs to manage an array of reset controls. + */ +/** + * of_reset_control_get_count - Count number of resets available with a device + * + * @node: device node that contains 'resets'. + * + * Returns positive reset count on success, or error number on failure and + * on count being zero. + */ +static int of_reset_control_get_count(struct device_node *node) +{ + int count; + + if (!node) + return -EINVAL; + + count = of_count_phandle_with_args(node, "resets", "#reset-cells"); + if (count == 0) + count = -ENOENT; + + return count; +} + +/** + * reset_control_array_assert: assert a list of resets + * + * @resets: reset control array holding info about the list of resets + * + * This API doesn't guarantee that the reset lines controlled by + * the reset array are asserted in any particular order. + * + * Returns 0 on success or error number on failure. + */ +int reset_control_array_assert(struct reset_control_array *resets) +{ + int ret, i; + + if (!resets) + return 0; + + if (IS_ERR(resets)) + return -EINVAL; + + for (i = 0; i < resets->num_rstcs; i++) { + ret = reset_control_assert(resets->rstc[i]); + if (ret) + goto err; + } + + return 0; + +err: + while (i--) + reset_control_deassert(resets->rstc[i]); + return ret; +} +EXPORT_SYMBOL_GPL(reset_control_array_assert); + +/** + * reset_control_array_deassert: deassert a list of resets + * + * @resets: reset control array holding info about the list of resets + * + * This API doesn't guarantee that the reset lines controlled by + * the reset array are deasserted in any particular order. + * + * Returns 0 on success or error number on failure. + */ +int reset_control_array_deassert(struct reset_control_array *resets) +{ + int ret, i; + + if (!resets) + return 0; + + if (IS_ERR(resets)) + return -EINVAL; + + for (i = 0; i < resets->num_rstcs; i++) { + ret = reset_control_deassert(resets->rstc[i]); + if (ret) + goto err; + } + + return 0; + +err: + while (i--) + reset_control_assert(resets->rstc[i]); + return ret; +} +EXPORT_SYMBOL_GPL(reset_control_array_deassert); + +static void devm_reset_control_array_release(struct device *dev, void *res) +{ + struct reset_control_array *resets = res; + + reset_control_array_put(resets); +} + +/** + * of_reset_control_array_get - Get a list of reset controls using + * device node. + * + * @np: device node for the device that requests the reset controls array + * @shared: whether reset controls are shared or not + * @optional: whether it is optional to get the reset controls + * + * Returns pointer to allocated reset_control_array on success or + * error on failure + */ +struct reset_control_array * +of_reset_control_array_get(struct device_node *np, bool shared, bool optional) +{ + struct reset_control_array *resets; + struct reset_control *rstc; + int num, i; + void *err; + + num = of_reset_control_get_count(np); + if (num < 0) + return optional ? NULL : ERR_PTR(num); + + resets = kzalloc(sizeof(*resets) + sizeof(resets->rstc[0]) * num, + GFP_KERNEL); + if (!resets) + return ERR_PTR(-ENOMEM); + + for (i = 0; i < num; i++) { + rstc = __of_reset_control_get(np, NULL, i, shared, optional); + if (IS_ERR(rstc)) { + err = ERR_CAST(rstc); + goto err_rst; + } + resets->rstc[i] = rstc; + } + resets->num_rstcs = num; + + return resets; + +err_rst: + while (--i >= 0) + reset_control_put(resets->rstc[i]); + + kfree(resets); + + return err; +} +EXPORT_SYMBOL_GPL(of_reset_control_array_get); + +/** + * devm_reset_control_array_get - Resource managed reset control array get + * + * @dev: device that requests the list of reset controls + * @shared: whether reset controls are shared or not + * @optional: whether it is optional to get the reset controls + * + * The reset control array APIs are intended for a list of resets + * that just have to be asserted or deasserted, without any + * requirements on the order. + * + * Returns pointer to allocated reset_control_array on success or + * error on failure + */ +struct reset_control_array * +devm_reset_control_array_get(struct device *dev, bool shared, bool optional) +{ + struct reset_control_array **devres; + struct reset_control_array *resets; + + devres = devres_alloc(devm_reset_control_array_release, + sizeof(*devres), GFP_KERNEL); + if (!devres) + return ERR_PTR(-ENOMEM); + + resets = of_reset_control_array_get(dev->of_node, shared, optional); + if (IS_ERR(resets)) { + devres_free(resets); + return resets; + } + + *devres = resets; + devres_add(dev, devres); + + return resets; +} +EXPORT_SYMBOL_GPL(devm_reset_control_array_get); + +void reset_control_array_put(struct reset_control_array *resets) +{ + int i; + + if (IS_ERR_OR_NULL(resets)) + return; + + for (i = 0; i < resets->num_rstcs; i++) + reset_control_put(resets->rstc[i]); + + kfree(resets); +} +EXPORT_SYMBOL_GPL(reset_control_array_put); diff --git a/include/linux/reset.h b/include/linux/reset.h index 13d8681210d5..df75fe50f765 100644 --- a/include/linux/reset.h +++ b/include/linux/reset.h @@ -5,6 +5,11 @@ struct reset_control; +struct reset_control_array { + unsigned int num_rstcs; + struct reset_control *rstc[]; +}; + #ifdef CONFIG_RESET_CONTROLLER int reset_control_reset(struct reset_control *rstc); @@ -25,6 +30,14 @@ struct reset_control *__devm_reset_control_get(struct device *dev, int __must_check device_reset(struct device *dev); +int reset_control_array_assert(struct reset_control_array *resets); +int reset_control_array_deassert(struct reset_control_array *resets); +struct reset_control_array *devm_reset_control_array_get(struct device *dev, + bool shared, bool optional); +struct reset_control_array *of_reset_control_array_get(struct device_node *np, + bool shared, bool optional); +void reset_control_array_put(struct reset_control_array *resets); + static inline int device_reset_optional(struct device *dev) { return device_reset(dev); @@ -89,6 +102,35 @@ static inline struct reset_control *__devm_reset_control_get( return optional ? NULL : ERR_PTR(-ENOTSUPP); } +static inline +int reset_control_array_assert(struct reset_control_array *resets) +{ + return 0; +} + +static inline +int reset_control_array_deassert(struct reset_control_array *resets) +{ + return 0; +} + +static inline struct reset_control_array * +devm_reset_control_array_get(struct device *dev, bool shared, bool optional) +{ + return optional ? NULL : ERR_PTR(-ENOTSUPP); +} + +static inline struct reset_control_array * +of_reset_control_array_get(struct device_node *np, bool shared, bool optional) +{ + return optional ? NULL : ERR_PTR(-ENOTSUPP); +} + +static inline +void reset_control_array_put(struct reset_control_array *resets) +{ +} + #endif /* CONFIG_RESET_CONTROLLER */ /** @@ -374,4 +416,55 @@ static inline struct reset_control *devm_reset_control_get_by_index( { return devm_reset_control_get_exclusive_by_index(dev, index); } + +/* + * APIs to manage a list of reset controllers + */ +static inline struct reset_control_array * +devm_reset_control_array_get_exclusive(struct device *dev) +{ + return devm_reset_control_array_get(dev, false, false); +} + +static inline struct reset_control_array * +devm_reset_control_array_get_shared(struct device *dev) +{ + return devm_reset_control_array_get(dev, true, false); +} + +static inline struct reset_control_array * +devm_reset_control_array_get_optional_exclusive(struct device *dev) +{ + return devm_reset_control_array_get(dev, false, true); +} + +static inline struct reset_control_array * +devm_reset_control_array_get_optional_shared(struct device *dev) +{ + return devm_reset_control_array_get(dev, true, true); +} + +static inline struct reset_control_array * +of_reset_control_array_get_exclusive(struct device_node *node) +{ + return of_reset_control_array_get(node, false, false); +} + +static inline struct reset_control_array * +of_reset_control_array_get_shared(struct device_node *node) +{ + return of_reset_control_array_get(node, true, false); +} + +static inline struct reset_control_array * +of_reset_control_array_get_optional_exclusive(struct device_node *node) +{ + return of_reset_control_array_get(node, false, true); +} + +static inline struct reset_control_array * +of_reset_control_array_get_optional_shared(struct device_node *node) +{ + return of_reset_control_array_get(node, true, true); +} #endif -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v4 3/4] usb: dwc3: of-simple: Add support to get resets for the device 2017-05-22 11:23 [PATCH v4 0/4] reset: APIs to manage a list of resets Vivek Gautam [not found] ` <1495452207-6129-1-git-send-email-vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> @ 2017-05-22 11:23 ` Vivek Gautam 2017-05-22 11:23 ` [PATCH v4 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers Vivek Gautam 2 siblings, 0 replies; 13+ messages in thread From: Vivek Gautam @ 2017-05-22 11:23 UTC (permalink / raw) To: p.zabel, linux-kernel Cc: linux-tegra, linux-usb, jonathanh, balbi, gregkh, linux-arm-msm, Vivek Gautam Add support to get a list of resets available for the device. These resets must be kept de-asserted until the device is in use. Cc: Felipe Balbi <balbi@kernel.org> Cc: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> --- drivers/usb/dwc3/dwc3-of-simple.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index a9bac09d3750..463b744d6688 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c @@ -29,11 +29,13 @@ #include <linux/of.h> #include <linux/of_platform.h> #include <linux/pm_runtime.h> +#include <linux/reset.h> struct dwc3_of_simple { struct device *dev; struct clk **clks; int num_clocks; + struct reset_control_array *resets; }; static int dwc3_of_simple_clk_init(struct dwc3_of_simple *simple, int count) @@ -96,9 +98,20 @@ static int dwc3_of_simple_probe(struct platform_device *pdev) platform_set_drvdata(pdev, simple); simple->dev = dev; + simple->resets = of_reset_control_array_get_optional_exclusive(np); + if (IS_ERR(simple->resets)) { + ret = PTR_ERR(simple->resets); + dev_err(dev, "failed to get device resets, err=%d\n", ret); + return ret; + } + + ret = reset_control_array_deassert(simple->resets); + if (ret) + goto err_resetc_put; + ret = dwc3_of_simple_clk_init(simple, of_clk_get_parent_count(np)); if (ret) - return ret; + goto err_resetc_assert; ret = of_platform_populate(np, NULL, NULL, dev); if (ret) { @@ -107,7 +120,7 @@ static int dwc3_of_simple_probe(struct platform_device *pdev) clk_put(simple->clks[i]); } - return ret; + goto err_resetc_assert; } pm_runtime_set_active(dev); @@ -115,6 +128,13 @@ static int dwc3_of_simple_probe(struct platform_device *pdev) pm_runtime_get_sync(dev); return 0; + +err_resetc_assert: + reset_control_array_assert(simple->resets); + +err_resetc_put: + reset_control_array_put(simple->resets); + return ret; } static int dwc3_of_simple_remove(struct platform_device *pdev) @@ -130,6 +150,9 @@ static int dwc3_of_simple_remove(struct platform_device *pdev) clk_put(simple->clks[i]); } + reset_control_array_assert(simple->resets); + reset_control_array_put(simple->resets); + pm_runtime_put_sync(dev); pm_runtime_disable(dev); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v4 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers 2017-05-22 11:23 [PATCH v4 0/4] reset: APIs to manage a list of resets Vivek Gautam [not found] ` <1495452207-6129-1-git-send-email-vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> 2017-05-22 11:23 ` [PATCH v4 3/4] usb: dwc3: of-simple: Add support to get resets for the device Vivek Gautam @ 2017-05-22 11:23 ` Vivek Gautam [not found] ` <1495452207-6129-5-git-send-email-vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> 2 siblings, 1 reply; 13+ messages in thread From: Vivek Gautam @ 2017-05-22 11:23 UTC (permalink / raw) To: p.zabel, linux-kernel Cc: linux-tegra, linux-usb, jonathanh, balbi, gregkh, linux-arm-msm, Vivek Gautam, Thierry Reding Make use of reset_control_array_*() set of APIs to manage an array of reset controllers available with the device. Cc: Jon Hunter <jonathanh@nvidia.com> Cc: Thierry Reding <treding@nvidia.com> Cc: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> --- drivers/soc/tegra/pmc.c | 91 +++++++++++++++++-------------------------------- 1 file changed, 31 insertions(+), 60 deletions(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index e233dd5dcab3..668f5d3d3635 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -124,8 +124,8 @@ struct tegra_powergate { unsigned int id; struct clk **clks; unsigned int num_clks; - struct reset_control **resets; - unsigned int num_resets; + struct reset_control *reset; + struct reset_control_array *resets; }; struct tegra_io_pad_soc { @@ -348,32 +348,20 @@ static int tegra_powergate_enable_clocks(struct tegra_powergate *pg) return err; } -static int tegra_powergate_reset_assert(struct tegra_powergate *pg) +static inline int tegra_powergate_reset_assert(struct tegra_powergate *pg) { - unsigned int i; - int err; + if (!IS_ERR_OR_NULL(pg->reset)) + return reset_control_assert(pg->reset); - for (i = 0; i < pg->num_resets; i++) { - err = reset_control_assert(pg->resets[i]); - if (err) - return err; - } - - return 0; + return reset_control_array_assert(pg->resets); } -static int tegra_powergate_reset_deassert(struct tegra_powergate *pg) +static inline int tegra_powergate_reset_deassert(struct tegra_powergate *pg) { - unsigned int i; - int err; + if (!IS_ERR_OR_NULL(pg->reset)) + return reset_control_deassert(pg->reset); - for (i = 0; i < pg->num_resets; i++) { - err = reset_control_deassert(pg->resets[i]); - if (err) - return err; - } - - return 0; + return reset_control_array_deassert(pg->resets); } static int tegra_powergate_power_up(struct tegra_powergate *pg, @@ -566,8 +554,13 @@ int tegra_powergate_sequence_power_up(unsigned int id, struct clk *clk, pg.id = id; pg.clks = &clk; pg.num_clks = 1; - pg.resets = &rst; - pg.num_resets = 1; + + /* + * Handle the reset control passed from the client separately. + * So, the pmc will either have this single reset control, or, + * have a list of reset controls managed by the driver on its own. + */ + pg.reset = rst; err = tegra_powergate_power_up(&pg, false); if (err) @@ -755,45 +748,26 @@ static int tegra_powergate_of_get_clks(struct tegra_powergate *pg, static int tegra_powergate_of_get_resets(struct tegra_powergate *pg, struct device_node *np, bool off) { - struct reset_control *rst; - unsigned int i, count; int err; - count = of_count_phandle_with_args(np, "resets", "#reset-cells"); - if (count == 0) - return -ENODEV; - - pg->resets = kcalloc(count, sizeof(rst), GFP_KERNEL); - if (!pg->resets) - return -ENOMEM; - - for (i = 0; i < count; i++) { - pg->resets[i] = of_reset_control_get_by_index(np, i); - if (IS_ERR(pg->resets[i])) { - err = PTR_ERR(pg->resets[i]); - goto error; - } - - if (off) - err = reset_control_assert(pg->resets[i]); - else - err = reset_control_deassert(pg->resets[i]); - - if (err) { - reset_control_put(pg->resets[i]); - goto error; - } + pg->resets = of_reset_control_array_get_exclusive(np); + if (IS_ERR(pg->resets)) { + pr_err("failed to get device resets\n"); + return PTR_ERR(pg->resets); } - pg->num_resets = count; + if (off) + err = reset_control_array_assert(pg->resets); + else + err = reset_control_array_deassert(pg->resets); - return 0; + if (err) + goto put_reset; -error: - while (i--) - reset_control_put(pg->resets[i]); + return 0; - kfree(pg->resets); +put_reset: + reset_control_array_put(pg->resets); return err; } @@ -885,10 +859,7 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, struct device_node *np) pm_genpd_remove(&pg->genpd); remove_resets: - while (pg->num_resets--) - reset_control_put(pg->resets[pg->num_resets]); - - kfree(pg->resets); + reset_control_array_put(pg->resets); remove_clks: while (pg->num_clks--) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply related [flat|nested] 13+ messages in thread
[parent not found: <1495452207-6129-5-git-send-email-vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>]
* Re: [PATCH v4 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers 2017-05-22 11:23 ` [PATCH v4 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers Vivek Gautam @ 2017-05-31 14:23 ` Jon Hunter 0 siblings, 0 replies; 13+ messages in thread From: Jon Hunter @ 2017-05-31 14:23 UTC (permalink / raw) To: Vivek Gautam, p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-DgEjT+Ai2ygdnm+yROfE0A, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, linux-arm-msm-u79uwXL29TY76Z2rM5mHXA, Thierry Reding On 22/05/17 12:23, Vivek Gautam wrote: > Make use of reset_control_array_*() set of APIs to manage > an array of reset controllers available with the device. > > Cc: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > Cc: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > Cc: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> > Signed-off-by: Vivek Gautam <vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> > --- > drivers/soc/tegra/pmc.c | 91 +++++++++++++++++-------------------------------- > 1 file changed, 31 insertions(+), 60 deletions(-) > > diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c > index e233dd5dcab3..668f5d3d3635 100644 > --- a/drivers/soc/tegra/pmc.c > +++ b/drivers/soc/tegra/pmc.c > @@ -124,8 +124,8 @@ struct tegra_powergate { > unsigned int id; > struct clk **clks; > unsigned int num_clks; > - struct reset_control **resets; > - unsigned int num_resets; > + struct reset_control *reset; > + struct reset_control_array *resets; It's a shame we can't avoid this additional reset pointer, but maybe there is no good alternative for now. So ... Acked-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> Tested-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> Cheers Jon -- nvpublic -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v4 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers @ 2017-05-31 14:23 ` Jon Hunter 0 siblings, 0 replies; 13+ messages in thread From: Jon Hunter @ 2017-05-31 14:23 UTC (permalink / raw) To: Vivek Gautam, p.zabel, linux-kernel Cc: linux-tegra, linux-usb, balbi, gregkh, linux-arm-msm, Thierry Reding On 22/05/17 12:23, Vivek Gautam wrote: > Make use of reset_control_array_*() set of APIs to manage > an array of reset controllers available with the device. > > Cc: Jon Hunter <jonathanh@nvidia.com> > Cc: Thierry Reding <treding@nvidia.com> > Cc: Philipp Zabel <p.zabel@pengutronix.de> > Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> > --- > drivers/soc/tegra/pmc.c | 91 +++++++++++++++++-------------------------------- > 1 file changed, 31 insertions(+), 60 deletions(-) > > diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c > index e233dd5dcab3..668f5d3d3635 100644 > --- a/drivers/soc/tegra/pmc.c > +++ b/drivers/soc/tegra/pmc.c > @@ -124,8 +124,8 @@ struct tegra_powergate { > unsigned int id; > struct clk **clks; > unsigned int num_clks; > - struct reset_control **resets; > - unsigned int num_resets; > + struct reset_control *reset; > + struct reset_control_array *resets; It's a shame we can't avoid this additional reset pointer, but maybe there is no good alternative for now. So ... Acked-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Cheers Jon -- nvpublic ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <53360973-098e-14fa-88e9-b0864822359a-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH v4 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers 2017-05-31 14:23 ` Jon Hunter @ 2017-06-01 6:35 ` Vivek Gautam -1 siblings, 0 replies; 13+ messages in thread From: Vivek Gautam @ 2017-06-01 6:35 UTC (permalink / raw) To: Jon Hunter Cc: Philipp Zabel, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-tegra, Linux USB Mailing List, Felipe Balbi, Greg KH, linux-arm-msm-u79uwXL29TY76Z2rM5mHXA, Thierry Reding Hi, On Wed, May 31, 2017 at 7:53 PM, Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote: > > On 22/05/17 12:23, Vivek Gautam wrote: >> Make use of reset_control_array_*() set of APIs to manage >> an array of reset controllers available with the device. >> >> Cc: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> >> Cc: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> >> Cc: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> >> Signed-off-by: Vivek Gautam <vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> >> --- >> drivers/soc/tegra/pmc.c | 91 +++++++++++++++++-------------------------------- >> 1 file changed, 31 insertions(+), 60 deletions(-) >> >> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c >> index e233dd5dcab3..668f5d3d3635 100644 >> --- a/drivers/soc/tegra/pmc.c >> +++ b/drivers/soc/tegra/pmc.c >> @@ -124,8 +124,8 @@ struct tegra_powergate { >> unsigned int id; >> struct clk **clks; >> unsigned int num_clks; >> - struct reset_control **resets; >> - unsigned int num_resets; >> + struct reset_control *reset; >> + struct reset_control_array *resets; > > It's a shame we can't avoid this additional reset pointer, but maybe > there is no good alternative for now. So ... > > Acked-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > Tested-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> Thanks for the testing and Ack. Best regards Vivek > > Cheers > Jon > > -- > nvpublic > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v4 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers @ 2017-06-01 6:35 ` Vivek Gautam 0 siblings, 0 replies; 13+ messages in thread From: Vivek Gautam @ 2017-06-01 6:35 UTC (permalink / raw) To: Jon Hunter Cc: Philipp Zabel, linux-kernel, linux-tegra, Linux USB Mailing List, Felipe Balbi, Greg KH, linux-arm-msm, Thierry Reding Hi, On Wed, May 31, 2017 at 7:53 PM, Jon Hunter <jonathanh@nvidia.com> wrote: > > On 22/05/17 12:23, Vivek Gautam wrote: >> Make use of reset_control_array_*() set of APIs to manage >> an array of reset controllers available with the device. >> >> Cc: Jon Hunter <jonathanh@nvidia.com> >> Cc: Thierry Reding <treding@nvidia.com> >> Cc: Philipp Zabel <p.zabel@pengutronix.de> >> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> >> --- >> drivers/soc/tegra/pmc.c | 91 +++++++++++++++++-------------------------------- >> 1 file changed, 31 insertions(+), 60 deletions(-) >> >> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c >> index e233dd5dcab3..668f5d3d3635 100644 >> --- a/drivers/soc/tegra/pmc.c >> +++ b/drivers/soc/tegra/pmc.c >> @@ -124,8 +124,8 @@ struct tegra_powergate { >> unsigned int id; >> struct clk **clks; >> unsigned int num_clks; >> - struct reset_control **resets; >> - unsigned int num_resets; >> + struct reset_control *reset; >> + struct reset_control_array *resets; > > It's a shame we can't avoid this additional reset pointer, but maybe > there is no good alternative for now. So ... > > Acked-by: Jon Hunter <jonathanh@nvidia.com> > Tested-by: Jon Hunter <jonathanh@nvidia.com> Thanks for the testing and Ack. Best regards Vivek > > Cheers > Jon > > -- > nvpublic > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v4 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers 2017-05-31 14:23 ` Jon Hunter @ 2017-06-01 16:44 ` Philipp Zabel -1 siblings, 0 replies; 13+ messages in thread From: Philipp Zabel @ 2017-06-01 16:44 UTC (permalink / raw) To: Jon Hunter Cc: Vivek Gautam, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-tegra-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-DgEjT+Ai2ygdnm+yROfE0A, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, linux-arm-msm-u79uwXL29TY76Z2rM5mHXA, Thierry Reding Hi, On Wed, 2017-05-31 at 15:23 +0100, Jon Hunter wrote: > On 22/05/17 12:23, Vivek Gautam wrote: > > Make use of reset_control_array_*() set of APIs to manage > > an array of reset controllers available with the device. > > > > Cc: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > > Cc: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > > Cc: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> > > Signed-off-by: Vivek Gautam <vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> > > --- > > drivers/soc/tegra/pmc.c | 91 +++++++++++++++++-------------------------------- > > 1 file changed, 31 insertions(+), 60 deletions(-) > > > > diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c > > index e233dd5dcab3..668f5d3d3635 100644 > > --- a/drivers/soc/tegra/pmc.c > > +++ b/drivers/soc/tegra/pmc.c > > @@ -124,8 +124,8 @@ struct tegra_powergate { > > unsigned int id; > > struct clk **clks; > > unsigned int num_clks; > > - struct reset_control **resets; > > - unsigned int num_resets; > > + struct reset_control *reset; > > + struct reset_control_array *resets; > > It's a shame we can't avoid this additional reset pointer, but maybe > there is no good alternative for now. So ... > > Acked-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > Tested-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> Thanks. I don't see a big functional difference between a reset_control_array and a reset_control, given that a single reset control bit already controls multiple reset lines on some devices. Maybe it would be preferable to let the reset_control_array_get functions return a struct reset_control that hides the array. I'll send a v5 to see if that would be sensible. regards Philipp ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v4 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers @ 2017-06-01 16:44 ` Philipp Zabel 0 siblings, 0 replies; 13+ messages in thread From: Philipp Zabel @ 2017-06-01 16:44 UTC (permalink / raw) To: Jon Hunter Cc: Vivek Gautam, linux-kernel, linux-tegra, linux-usb, balbi, gregkh, linux-arm-msm, Thierry Reding Hi, On Wed, 2017-05-31 at 15:23 +0100, Jon Hunter wrote: > On 22/05/17 12:23, Vivek Gautam wrote: > > Make use of reset_control_array_*() set of APIs to manage > > an array of reset controllers available with the device. > > > > Cc: Jon Hunter <jonathanh@nvidia.com> > > Cc: Thierry Reding <treding@nvidia.com> > > Cc: Philipp Zabel <p.zabel@pengutronix.de> > > Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> > > --- > > drivers/soc/tegra/pmc.c | 91 +++++++++++++++++-------------------------------- > > 1 file changed, 31 insertions(+), 60 deletions(-) > > > > diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c > > index e233dd5dcab3..668f5d3d3635 100644 > > --- a/drivers/soc/tegra/pmc.c > > +++ b/drivers/soc/tegra/pmc.c > > @@ -124,8 +124,8 @@ struct tegra_powergate { > > unsigned int id; > > struct clk **clks; > > unsigned int num_clks; > > - struct reset_control **resets; > > - unsigned int num_resets; > > + struct reset_control *reset; > > + struct reset_control_array *resets; > > It's a shame we can't avoid this additional reset pointer, but maybe > there is no good alternative for now. So ... > > Acked-by: Jon Hunter <jonathanh@nvidia.com> > Tested-by: Jon Hunter <jonathanh@nvidia.com> Thanks. I don't see a big functional difference between a reset_control_array and a reset_control, given that a single reset control bit already controls multiple reset lines on some devices. Maybe it would be preferable to let the reset_control_array_get functions return a struct reset_control that hides the array. I'll send a v5 to see if that would be sensible. regards Philipp ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2017-06-01 16:44 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-05-22 11:23 [PATCH v4 0/4] reset: APIs to manage a list of resets Vivek Gautam [not found] ` <1495452207-6129-1-git-send-email-vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> 2017-05-22 11:23 ` [PATCH v4 1/4] usb: dwc3: of-simple: Re-order resource handling in remove Vivek Gautam 2017-05-22 11:23 ` Vivek Gautam 2017-05-22 11:23 ` [PATCH v4 2/4] reset: Add APIs to manage array of resets Vivek Gautam 2017-05-22 11:23 ` Vivek Gautam 2017-05-22 11:23 ` [PATCH v4 3/4] usb: dwc3: of-simple: Add support to get resets for the device Vivek Gautam 2017-05-22 11:23 ` [PATCH v4 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers Vivek Gautam [not found] ` <1495452207-6129-5-git-send-email-vivek.gautam-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> 2017-05-31 14:23 ` Jon Hunter 2017-05-31 14:23 ` Jon Hunter [not found] ` <53360973-098e-14fa-88e9-b0864822359a-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> 2017-06-01 6:35 ` Vivek Gautam 2017-06-01 6:35 ` Vivek Gautam 2017-06-01 16:44 ` Philipp Zabel 2017-06-01 16:44 ` Philipp Zabel
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.