From: Lokesh Vutla <lokeshvutla@ti.com> To: Marc Zyngier <maz@kernel.org>, Rob Herring <robh+dt@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de>, Nishanth Menon <nm@ti.com>, Tero Kristo <t-kristo@ti.com>, Santosh Shilimkar <ssantosh@kernel.org>, Linux ARM Mailing List <linux-arm-kernel@lists.infradead.org>, Sekhar Nori <nsekhar@ti.com>, Grygorii Strashko <grygorii.strashko@ti.com>, Peter Ujfalusi <peter.ujfalusi@ti.com>, Device Tree Mailing List <devicetree@vger.kernel.org>, Suman Anna <s-anna@ti.com>, Lokesh Vutla <lokeshvutla@ti.com> Subject: [PATCH v6 03/13] firmware: ti_sci: Add support for getting resource with subtype Date: Thu, 6 Aug 2020 13:18:16 +0530 [thread overview] Message-ID: <20200806074826.24607-4-lokeshvutla@ti.com> (raw) In-Reply-To: <20200806074826.24607-1-lokeshvutla@ti.com> With SYSFW ABI 3.0 changes, interrupts coming out of an interrupt controller is identified by a type and it is consistent across SoCs. Similarly global events for Interrupt aggregator. So add an API to get resource range using a resource type. Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> --- drivers/firmware/ti_sci.c | 89 +++++++++++++++++++------- include/linux/soc/ti/ti_sci_protocol.h | 13 ++++ 2 files changed, 80 insertions(+), 22 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 03bd01ba5fe7..722af9ee53d6 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -3208,61 +3208,50 @@ u32 ti_sci_get_num_resources(struct ti_sci_resource *res) EXPORT_SYMBOL_GPL(ti_sci_get_num_resources); /** - * devm_ti_sci_get_of_resource() - Get a TISCI resource assigned to a device + * devm_ti_sci_get_resource_sets() - Get a TISCI resources assigned to a device * @handle: TISCI handle * @dev: Device pointer to which the resource is assigned * @dev_id: TISCI device id to which the resource is assigned - * @of_prop: property name by which the resource are represented + * @sub_types: Array of sub_types assigned corresponding to device + * @sets: Number of sub_types * * Return: Pointer to ti_sci_resource if all went well else appropriate * error pointer. */ -struct ti_sci_resource * -devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, - struct device *dev, u32 dev_id, char *of_prop) +static struct ti_sci_resource * +devm_ti_sci_get_resource_sets(const struct ti_sci_handle *handle, + struct device *dev, u32 dev_id, u32 *sub_types, + u32 sets) { struct ti_sci_resource *res; bool valid_set = false; - u32 resource_subtype; int i, ret; res = devm_kzalloc(dev, sizeof(*res), GFP_KERNEL); if (!res) return ERR_PTR(-ENOMEM); - ret = of_property_count_elems_of_size(dev_of_node(dev), of_prop, - sizeof(u32)); - if (ret < 0) { - dev_err(dev, "%s resource type ids not available\n", of_prop); - return ERR_PTR(ret); - } - res->sets = ret; - + res->sets = sets; res->desc = devm_kcalloc(dev, res->sets, sizeof(*res->desc), GFP_KERNEL); if (!res->desc) return ERR_PTR(-ENOMEM); for (i = 0; i < res->sets; i++) { - ret = of_property_read_u32_index(dev_of_node(dev), of_prop, i, - &resource_subtype); - if (ret) - return ERR_PTR(-EINVAL); - ret = handle->ops.rm_core_ops.get_range(handle, dev_id, - resource_subtype, + sub_types[i], &res->desc[i].start, &res->desc[i].num); if (ret) { dev_dbg(dev, "dev = %d subtype %d not allocated for this host\n", - dev_id, resource_subtype); + dev_id, sub_types[i]); res->desc[i].start = 0; res->desc[i].num = 0; continue; } dev_dbg(dev, "dev = %d, subtype = %d, start = %d, num = %d\n", - dev_id, resource_subtype, res->desc[i].start, + dev_id, sub_types[i], res->desc[i].start, res->desc[i].num); valid_set = true; @@ -3280,6 +3269,62 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, return ERR_PTR(-EINVAL); } +/** + * devm_ti_sci_get_of_resource() - Get a TISCI resource assigned to a device + * @handle: TISCI handle + * @dev: Device pointer to which the resource is assigned + * @dev_id: TISCI device id to which the resource is assigned + * @of_prop: property name by which the resource are represented + * + * Return: Pointer to ti_sci_resource if all went well else appropriate + * error pointer. + */ +struct ti_sci_resource * +devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, + struct device *dev, u32 dev_id, char *of_prop) +{ + struct ti_sci_resource *res; + u32 *sub_types; + int sets; + + sets = of_property_count_elems_of_size(dev_of_node(dev), of_prop, + sizeof(u32)); + if (sets < 0) { + dev_err(dev, "%s resource type ids not available\n", of_prop); + return ERR_PTR(sets); + } + + sub_types = kcalloc(sets, sizeof(*sub_types), GFP_KERNEL); + if (!sub_types) + return ERR_PTR(-ENOMEM); + + of_property_read_u32_array(dev_of_node(dev), of_prop, sub_types, sets); + res = devm_ti_sci_get_resource_sets(handle, dev, dev_id, sub_types, + sets); + + kfree(sub_types); + return res; +} +EXPORT_SYMBOL_GPL(devm_ti_sci_get_of_resource); + +/** + * devm_ti_sci_get_resource() - Get a resource range assigned to the device + * @handle: TISCI handle + * @dev: Device pointer to which the resource is assigned + * @dev_id: TISCI device id to which the resource is assigned + * @suub_type: TISCI resource subytpe representing the resource. + * + * Return: Pointer to ti_sci_resource if all went well else appropriate + * error pointer. + */ +struct ti_sci_resource * +devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev, + u32 dev_id, u32 sub_type) +{ + return devm_ti_sci_get_resource_sets(handle, dev, dev_id, &sub_type, 1); +} +EXPORT_SYMBOL_GPL(devm_ti_sci_get_resource); + static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode, void *cmd) { diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/ti_sci_protocol.h index 49c5d29cd33c..cf27b080e148 100644 --- a/include/linux/soc/ti/ti_sci_protocol.h +++ b/include/linux/soc/ti/ti_sci_protocol.h @@ -220,6 +220,9 @@ struct ti_sci_rm_core_ops { u16 *range_start, u16 *range_num); }; +#define TI_SCI_RESASG_SUBTYPE_IR_OUTPUT 0 +#define TI_SCI_RESASG_SUBTYPE_IA_VINT 0xa +#define TI_SCI_RESASG_SUBTYPE_GLOBAL_EVENT_SEVT 0xd /** * struct ti_sci_rm_irq_ops: IRQ management operations * @set_irq: Set an IRQ route between the requested source @@ -556,6 +559,9 @@ u32 ti_sci_get_num_resources(struct ti_sci_resource *res); struct ti_sci_resource * devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, struct device *dev, u32 dev_id, char *of_prop); +struct ti_sci_resource * +devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev, + u32 dev_id, u32 sub_type); #else /* CONFIG_TI_SCI_PROTOCOL */ @@ -609,6 +615,13 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, { return ERR_PTR(-EINVAL); } + +static inline struct ti_sci_resource * +devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev, + u32 dev_id, u32 sub_type); +{ + return ERR_PTR(-EINVAL); +} #endif /* CONFIG_TI_SCI_PROTOCOL */ #endif /* __TISCI_PROTOCOL_H */ -- 2.27.0
WARNING: multiple messages have this Message-ID (diff)
From: Lokesh Vutla <lokeshvutla@ti.com> To: Marc Zyngier <maz@kernel.org>, Rob Herring <robh+dt@kernel.org> Cc: Nishanth Menon <nm@ti.com>, Peter Ujfalusi <peter.ujfalusi@ti.com>, Grygorii Strashko <grygorii.strashko@ti.com>, Device Tree Mailing List <devicetree@vger.kernel.org>, Lokesh Vutla <lokeshvutla@ti.com>, Sekhar Nori <nsekhar@ti.com>, Tero Kristo <t-kristo@ti.com>, Santosh Shilimkar <ssantosh@kernel.org>, Thomas Gleixner <tglx@linutronix.de>, Linux ARM Mailing List <linux-arm-kernel@lists.infradead.org> Subject: [PATCH v6 03/13] firmware: ti_sci: Add support for getting resource with subtype Date: Thu, 6 Aug 2020 13:18:16 +0530 [thread overview] Message-ID: <20200806074826.24607-4-lokeshvutla@ti.com> (raw) In-Reply-To: <20200806074826.24607-1-lokeshvutla@ti.com> With SYSFW ABI 3.0 changes, interrupts coming out of an interrupt controller is identified by a type and it is consistent across SoCs. Similarly global events for Interrupt aggregator. So add an API to get resource range using a resource type. Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> --- drivers/firmware/ti_sci.c | 89 +++++++++++++++++++------- include/linux/soc/ti/ti_sci_protocol.h | 13 ++++ 2 files changed, 80 insertions(+), 22 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 03bd01ba5fe7..722af9ee53d6 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -3208,61 +3208,50 @@ u32 ti_sci_get_num_resources(struct ti_sci_resource *res) EXPORT_SYMBOL_GPL(ti_sci_get_num_resources); /** - * devm_ti_sci_get_of_resource() - Get a TISCI resource assigned to a device + * devm_ti_sci_get_resource_sets() - Get a TISCI resources assigned to a device * @handle: TISCI handle * @dev: Device pointer to which the resource is assigned * @dev_id: TISCI device id to which the resource is assigned - * @of_prop: property name by which the resource are represented + * @sub_types: Array of sub_types assigned corresponding to device + * @sets: Number of sub_types * * Return: Pointer to ti_sci_resource if all went well else appropriate * error pointer. */ -struct ti_sci_resource * -devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, - struct device *dev, u32 dev_id, char *of_prop) +static struct ti_sci_resource * +devm_ti_sci_get_resource_sets(const struct ti_sci_handle *handle, + struct device *dev, u32 dev_id, u32 *sub_types, + u32 sets) { struct ti_sci_resource *res; bool valid_set = false; - u32 resource_subtype; int i, ret; res = devm_kzalloc(dev, sizeof(*res), GFP_KERNEL); if (!res) return ERR_PTR(-ENOMEM); - ret = of_property_count_elems_of_size(dev_of_node(dev), of_prop, - sizeof(u32)); - if (ret < 0) { - dev_err(dev, "%s resource type ids not available\n", of_prop); - return ERR_PTR(ret); - } - res->sets = ret; - + res->sets = sets; res->desc = devm_kcalloc(dev, res->sets, sizeof(*res->desc), GFP_KERNEL); if (!res->desc) return ERR_PTR(-ENOMEM); for (i = 0; i < res->sets; i++) { - ret = of_property_read_u32_index(dev_of_node(dev), of_prop, i, - &resource_subtype); - if (ret) - return ERR_PTR(-EINVAL); - ret = handle->ops.rm_core_ops.get_range(handle, dev_id, - resource_subtype, + sub_types[i], &res->desc[i].start, &res->desc[i].num); if (ret) { dev_dbg(dev, "dev = %d subtype %d not allocated for this host\n", - dev_id, resource_subtype); + dev_id, sub_types[i]); res->desc[i].start = 0; res->desc[i].num = 0; continue; } dev_dbg(dev, "dev = %d, subtype = %d, start = %d, num = %d\n", - dev_id, resource_subtype, res->desc[i].start, + dev_id, sub_types[i], res->desc[i].start, res->desc[i].num); valid_set = true; @@ -3280,6 +3269,62 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, return ERR_PTR(-EINVAL); } +/** + * devm_ti_sci_get_of_resource() - Get a TISCI resource assigned to a device + * @handle: TISCI handle + * @dev: Device pointer to which the resource is assigned + * @dev_id: TISCI device id to which the resource is assigned + * @of_prop: property name by which the resource are represented + * + * Return: Pointer to ti_sci_resource if all went well else appropriate + * error pointer. + */ +struct ti_sci_resource * +devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, + struct device *dev, u32 dev_id, char *of_prop) +{ + struct ti_sci_resource *res; + u32 *sub_types; + int sets; + + sets = of_property_count_elems_of_size(dev_of_node(dev), of_prop, + sizeof(u32)); + if (sets < 0) { + dev_err(dev, "%s resource type ids not available\n", of_prop); + return ERR_PTR(sets); + } + + sub_types = kcalloc(sets, sizeof(*sub_types), GFP_KERNEL); + if (!sub_types) + return ERR_PTR(-ENOMEM); + + of_property_read_u32_array(dev_of_node(dev), of_prop, sub_types, sets); + res = devm_ti_sci_get_resource_sets(handle, dev, dev_id, sub_types, + sets); + + kfree(sub_types); + return res; +} +EXPORT_SYMBOL_GPL(devm_ti_sci_get_of_resource); + +/** + * devm_ti_sci_get_resource() - Get a resource range assigned to the device + * @handle: TISCI handle + * @dev: Device pointer to which the resource is assigned + * @dev_id: TISCI device id to which the resource is assigned + * @suub_type: TISCI resource subytpe representing the resource. + * + * Return: Pointer to ti_sci_resource if all went well else appropriate + * error pointer. + */ +struct ti_sci_resource * +devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev, + u32 dev_id, u32 sub_type) +{ + return devm_ti_sci_get_resource_sets(handle, dev, dev_id, &sub_type, 1); +} +EXPORT_SYMBOL_GPL(devm_ti_sci_get_resource); + static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode, void *cmd) { diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/ti_sci_protocol.h index 49c5d29cd33c..cf27b080e148 100644 --- a/include/linux/soc/ti/ti_sci_protocol.h +++ b/include/linux/soc/ti/ti_sci_protocol.h @@ -220,6 +220,9 @@ struct ti_sci_rm_core_ops { u16 *range_start, u16 *range_num); }; +#define TI_SCI_RESASG_SUBTYPE_IR_OUTPUT 0 +#define TI_SCI_RESASG_SUBTYPE_IA_VINT 0xa +#define TI_SCI_RESASG_SUBTYPE_GLOBAL_EVENT_SEVT 0xd /** * struct ti_sci_rm_irq_ops: IRQ management operations * @set_irq: Set an IRQ route between the requested source @@ -556,6 +559,9 @@ u32 ti_sci_get_num_resources(struct ti_sci_resource *res); struct ti_sci_resource * devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, struct device *dev, u32 dev_id, char *of_prop); +struct ti_sci_resource * +devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev, + u32 dev_id, u32 sub_type); #else /* CONFIG_TI_SCI_PROTOCOL */ @@ -609,6 +615,13 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, { return ERR_PTR(-EINVAL); } + +static inline struct ti_sci_resource * +devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev, + u32 dev_id, u32 sub_type); +{ + return ERR_PTR(-EINVAL); +} #endif /* CONFIG_TI_SCI_PROTOCOL */ #endif /* __TISCI_PROTOCOL_H */ -- 2.27.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-08-06 11:05 UTC|newest] Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-06 7:48 [PATCH v6 00/13] irqchip: ti,sci-intr/inta: Update the dt bindings to accept different interrupt parents Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 00/13] irqchip: ti, sci-intr/inta: " Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 01/13] firmware: ti_sci: Drop the device id to resource type translation Lokesh Vutla 2020-08-06 7:48 ` Lokesh Vutla 2020-08-25 23:41 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 02/13] firmware: ti_sci: Drop unused structure ti_sci_rm_type_map Lokesh Vutla 2020-08-06 7:48 ` Lokesh Vutla 2020-08-25 23:41 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-06 7:48 ` Lokesh Vutla [this message] 2020-08-06 7:48 ` [PATCH v6 03/13] firmware: ti_sci: Add support for getting resource with subtype Lokesh Vutla 2020-08-25 23:41 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 04/13] dt-bindings: irqchip: ti,sci-intr: Update bindings to drop the usage of gic as parent Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 04/13] dt-bindings: irqchip: ti, sci-intr: " Lokesh Vutla 2020-08-25 23:41 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 05/13] dt-bindings: irqchip: Convert ti,sci-intr bindings to yaml Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 05/13] dt-bindings: irqchip: Convert ti, sci-intr " Lokesh Vutla 2020-08-25 23:40 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 06/13] irqchip/ti-sci-intr: Add support for INTR being a parent to INTR Lokesh Vutla 2020-08-06 7:48 ` Lokesh Vutla 2020-08-25 23:40 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 07/13] dt-bindings: irqchip: ti,sci-inta: Update docs to support different parent Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 07/13] dt-bindings: irqchip: ti, sci-inta: " Lokesh Vutla 2020-08-25 23:40 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 08/13] dt-bindings: irqchip: Convert ti,sci-inta bindings to yaml Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 08/13] dt-bindings: irqchip: Convert ti, sci-inta " Lokesh Vutla 2020-08-25 23:40 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 09/13] irqchip/ti-sci-inta: Do not store TISCI device id in platform device id field Lokesh Vutla 2020-08-06 7:48 ` Lokesh Vutla 2020-08-25 23:40 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 10/13] irqchip/ti-sci-inta: Add support for INTA directly connecting to GIC Lokesh Vutla 2020-08-06 7:48 ` Lokesh Vutla 2020-08-25 23:40 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 11/13] arm64: dts: k3-j721e: ti-sci-inta/intr: Update to latest bindings Lokesh Vutla 2020-08-06 7:48 ` Lokesh Vutla 2020-08-12 13:35 ` Nishanth Menon 2020-08-12 13:35 ` Nishanth Menon 2020-08-25 23:40 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 12/13] arm64: dts: k3-am65: " Lokesh Vutla 2020-08-06 7:48 ` Lokesh Vutla 2020-08-12 13:35 ` Nishanth Menon 2020-08-12 13:35 ` Nishanth Menon 2020-08-25 23:40 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-06 7:48 ` [PATCH v6 13/13] arm64: dts: k3-am65: Update the RM resource types Lokesh Vutla 2020-08-06 7:48 ` Lokesh Vutla 2020-08-12 13:36 ` Nishanth Menon 2020-08-12 13:36 ` Nishanth Menon 2020-08-25 23:40 ` [tip: irq/urgent] " tip-bot2 for Lokesh Vutla 2020-08-07 6:32 ` [PATCH v6 00/13] irqchip: ti,sci-intr/inta: Update the dt bindings to accept different interrupt parents Lokesh Vutla 2020-08-07 6:32 ` Lokesh Vutla 2020-08-12 2:14 ` Lokesh Vutla 2020-08-12 2:14 ` Lokesh Vutla 2020-08-12 13:40 ` Nishanth Menon 2020-08-12 13:40 ` Nishanth Menon 2020-08-13 9:41 ` Peter Ujfalusi 2020-08-13 9:41 ` Peter Ujfalusi 2020-08-13 10:03 ` Sekhar Nori 2020-08-13 10:03 ` Sekhar Nori 2020-08-13 10:20 ` Peter Ujfalusi 2020-08-13 10:20 ` Peter Ujfalusi 2020-08-16 21:03 ` [PATCH v6 00/13] irqchip: ti, sci-intr/inta: " Marc Zyngier 2020-08-16 21:03 ` Marc Zyngier 2020-08-17 17:30 ` Sekhar Nori 2020-08-17 17:30 ` Sekhar Nori
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=20200806074826.24607-4-lokeshvutla@ti.com \ --to=lokeshvutla@ti.com \ --cc=devicetree@vger.kernel.org \ --cc=grygorii.strashko@ti.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=maz@kernel.org \ --cc=nm@ti.com \ --cc=nsekhar@ti.com \ --cc=peter.ujfalusi@ti.com \ --cc=robh+dt@kernel.org \ --cc=s-anna@ti.com \ --cc=ssantosh@kernel.org \ --cc=t-kristo@ti.com \ --cc=tglx@linutronix.de \ /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.