LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/2] typec: tcpm: Populate fwnode for use in power_supply core
@ 2018-05-22 15:16 Adam Thomson
2018-05-22 15:16 ` [PATCH 1/2] power: supply: Add fwnode pointer to power_supply_config struct Adam Thomson
2018-05-22 15:16 ` [PATCH 2/2] typec: tcpm: Provide fwnode pointer as part of psy_cfg Adam Thomson
0 siblings, 2 replies; 7+ messages in thread
From: Adam Thomson @ 2018-05-22 15:16 UTC (permalink / raw)
To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Sebastian Reichel
Cc: linux-usb, linux-pm, linux-kernel, support.opensource
This patch set adds support for passing a fwnode pointer as part of the psy
config structure, when intialising the psy core, so that calling code can be
written to be agnostic of the HW description required for the platform. The TCPM
code is updated subsequently to make use of this new field.
For now the main FW support in the psy core is still just DT based but in the
future ACPI will likely be added and can use this field.
Adam Thomson (2):
power: supply: Add fwnode pointer to power_supply_config struct
typec: tcpm: Provide fwnode pointer as part of psy_cfg
drivers/power/supply/power_supply_core.c | 4 +++-
drivers/usb/typec/tcpm.c | 2 ++
include/linux/power_supply.h | 2 ++
3 files changed, 7 insertions(+), 1 deletion(-)
--
1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] power: supply: Add fwnode pointer to power_supply_config struct
2018-05-22 15:16 [PATCH 0/2] typec: tcpm: Populate fwnode for use in power_supply core Adam Thomson
@ 2018-05-22 15:16 ` Adam Thomson
2018-05-22 16:15 ` Sebastian Reichel
2018-05-23 6:48 ` Heikki Krogerus
2018-05-22 15:16 ` [PATCH 2/2] typec: tcpm: Provide fwnode pointer as part of psy_cfg Adam Thomson
1 sibling, 2 replies; 7+ messages in thread
From: Adam Thomson @ 2018-05-22 15:16 UTC (permalink / raw)
To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Sebastian Reichel
Cc: linux-usb, linux-pm, linux-kernel, support.opensource
To allow users of the power supply framework to be hw description
agnostic, this commit adds the ability to pass a fwnode pointer,
via the power_supply_config structure, to the initialisation code
of the core, instead of explicitly specifying of_ndoe. If that
fwnode pointer is provided then it will automatically resolve down
to of_node on platforms which support it, otherwise it will be NULL.
In the future, when ACPI support is added, this can be modified to
accommodate ACPI without the need to change calling code which
already provides the fwnode handle in this manner.
Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
drivers/power/supply/power_supply_core.c | 4 +++-
include/linux/power_supply.h | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index ecd68c2..f57ab0a 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -19,6 +19,7 @@
#include <linux/err.h>
#include <linux/of.h>
#include <linux/power_supply.h>
+#include <linux/property.h>
#include <linux/thermal.h>
#include "power_supply.h"
@@ -874,7 +875,8 @@ static void psy_unregister_cooler(struct power_supply *psy)
psy->desc = desc;
if (cfg) {
psy->drv_data = cfg->drv_data;
- psy->of_node = cfg->of_node;
+ psy->of_node =
+ cfg->fwnode ? to_of_node(cfg->fwnode) : cfg->of_node;
psy->supplied_to = cfg->supplied_to;
psy->num_supplicants = cfg->num_supplicants;
}
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 0c9a572..b21c4bd9 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -199,6 +199,8 @@ enum power_supply_notifier_events {
/* Run-time specific power supply configuration */
struct power_supply_config {
struct device_node *of_node;
+ struct fwnode_handle *fwnode;
+
/* Driver private data */
void *drv_data;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] typec: tcpm: Provide fwnode pointer as part of psy_cfg
2018-05-22 15:16 [PATCH 0/2] typec: tcpm: Populate fwnode for use in power_supply core Adam Thomson
2018-05-22 15:16 ` [PATCH 1/2] power: supply: Add fwnode pointer to power_supply_config struct Adam Thomson
@ 2018-05-22 15:16 ` Adam Thomson
2018-05-22 16:08 ` Guenter Roeck
2018-05-23 6:52 ` Heikki Krogerus
1 sibling, 2 replies; 7+ messages in thread
From: Adam Thomson @ 2018-05-22 15:16 UTC (permalink / raw)
To: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, Sebastian Reichel
Cc: linux-usb, linux-pm, linux-kernel, support.opensource
For supply registration, provide fwnode pointer of the port device,
via the power_supply_config structure, to allow other psy drivers
to add us as a supplier. At present this only applies to DT
based platforms using the 'power-supplies' DT property, but in the
future should also work for ACPI platforms when the relevant support
is added to the power_supply core.
Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/usb/typec/tcpm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 72996cc..0ccd2ce 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -14,6 +14,7 @@
#include <linux/mutex.h>
#include <linux/power_supply.h>
#include <linux/proc_fs.h>
+#include <linux/property.h>
#include <linux/sched/clock.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
@@ -4500,6 +4501,7 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
char *psy_name;
psy_cfg.drv_data = port;
+ psy_cfg.fwnode = dev_fwnode(port->dev);
psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
if (!psy_name)
return -ENOMEM;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] typec: tcpm: Provide fwnode pointer as part of psy_cfg
2018-05-22 15:16 ` [PATCH 2/2] typec: tcpm: Provide fwnode pointer as part of psy_cfg Adam Thomson
@ 2018-05-22 16:08 ` Guenter Roeck
2018-05-23 6:52 ` Heikki Krogerus
1 sibling, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2018-05-22 16:08 UTC (permalink / raw)
To: Adam Thomson
Cc: Heikki Krogerus, Greg Kroah-Hartman, Sebastian Reichel,
linux-usb, linux-pm, linux-kernel, support.opensource
On Tue, May 22, 2018 at 04:16:24PM +0100, Adam Thomson wrote:
> For supply registration, provide fwnode pointer of the port device,
> via the power_supply_config structure, to allow other psy drivers
> to add us as a supplier. At present this only applies to DT
> based platforms using the 'power-supplies' DT property, but in the
> future should also work for ACPI platforms when the relevant support
> is added to the power_supply core.
>
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/usb/typec/tcpm.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 72996cc..0ccd2ce 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -14,6 +14,7 @@
> #include <linux/mutex.h>
> #include <linux/power_supply.h>
> #include <linux/proc_fs.h>
> +#include <linux/property.h>
> #include <linux/sched/clock.h>
> #include <linux/seq_file.h>
> #include <linux/slab.h>
> @@ -4500,6 +4501,7 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
> char *psy_name;
>
> psy_cfg.drv_data = port;
> + psy_cfg.fwnode = dev_fwnode(port->dev);
> psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
> if (!psy_name)
> return -ENOMEM;
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] power: supply: Add fwnode pointer to power_supply_config struct
2018-05-22 15:16 ` [PATCH 1/2] power: supply: Add fwnode pointer to power_supply_config struct Adam Thomson
@ 2018-05-22 16:15 ` Sebastian Reichel
2018-05-23 6:48 ` Heikki Krogerus
1 sibling, 0 replies; 7+ messages in thread
From: Sebastian Reichel @ 2018-05-22 16:15 UTC (permalink / raw)
To: Adam Thomson
Cc: Heikki Krogerus, Guenter Roeck, Greg Kroah-Hartman, linux-usb,
linux-pm, linux-kernel, support.opensource
[-- Attachment #1: Type: text/plain, Size: 2377 bytes --]
Hi,
On Tue, May 22, 2018 at 04:16:23PM +0100, Adam Thomson wrote:
> To allow users of the power supply framework to be hw description
> agnostic, this commit adds the ability to pass a fwnode pointer,
> via the power_supply_config structure, to the initialisation code
> of the core, instead of explicitly specifying of_ndoe. If that
> fwnode pointer is provided then it will automatically resolve down
> to of_node on platforms which support it, otherwise it will be NULL.
>
> In the future, when ACPI support is added, this can be modified to
> accommodate ACPI without the need to change calling code which
> already provides the fwnode handle in this manner.
>
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
-- Sebastian
> drivers/power/supply/power_supply_core.c | 4 +++-
> include/linux/power_supply.h | 2 ++
> 2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index ecd68c2..f57ab0a 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -19,6 +19,7 @@
> #include <linux/err.h>
> #include <linux/of.h>
> #include <linux/power_supply.h>
> +#include <linux/property.h>
> #include <linux/thermal.h>
> #include "power_supply.h"
>
> @@ -874,7 +875,8 @@ static void psy_unregister_cooler(struct power_supply *psy)
> psy->desc = desc;
> if (cfg) {
> psy->drv_data = cfg->drv_data;
> - psy->of_node = cfg->of_node;
> + psy->of_node =
> + cfg->fwnode ? to_of_node(cfg->fwnode) : cfg->of_node;
> psy->supplied_to = cfg->supplied_to;
> psy->num_supplicants = cfg->num_supplicants;
> }
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index 0c9a572..b21c4bd9 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -199,6 +199,8 @@ enum power_supply_notifier_events {
> /* Run-time specific power supply configuration */
> struct power_supply_config {
> struct device_node *of_node;
> + struct fwnode_handle *fwnode;
> +
> /* Driver private data */
> void *drv_data;
>
> --
> 1.9.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] power: supply: Add fwnode pointer to power_supply_config struct
2018-05-22 15:16 ` [PATCH 1/2] power: supply: Add fwnode pointer to power_supply_config struct Adam Thomson
2018-05-22 16:15 ` Sebastian Reichel
@ 2018-05-23 6:48 ` Heikki Krogerus
1 sibling, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2018-05-23 6:48 UTC (permalink / raw)
To: Adam Thomson
Cc: Guenter Roeck, Greg Kroah-Hartman, Sebastian Reichel, linux-usb,
linux-pm, linux-kernel, support.opensource
On Tue, May 22, 2018 at 04:16:23PM +0100, Adam Thomson wrote:
> To allow users of the power supply framework to be hw description
> agnostic, this commit adds the ability to pass a fwnode pointer,
> via the power_supply_config structure, to the initialisation code
> of the core, instead of explicitly specifying of_ndoe. If that
> fwnode pointer is provided then it will automatically resolve down
> to of_node on platforms which support it, otherwise it will be NULL.
>
> In the future, when ACPI support is added, this can be modified to
> accommodate ACPI without the need to change calling code which
> already provides the fwnode handle in this manner.
>
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Thanks Adam! FWIW:
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/power/supply/power_supply_core.c | 4 +++-
> include/linux/power_supply.h | 2 ++
> 2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index ecd68c2..f57ab0a 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -19,6 +19,7 @@
> #include <linux/err.h>
> #include <linux/of.h>
> #include <linux/power_supply.h>
> +#include <linux/property.h>
> #include <linux/thermal.h>
> #include "power_supply.h"
>
> @@ -874,7 +875,8 @@ static void psy_unregister_cooler(struct power_supply *psy)
> psy->desc = desc;
> if (cfg) {
> psy->drv_data = cfg->drv_data;
> - psy->of_node = cfg->of_node;
> + psy->of_node =
> + cfg->fwnode ? to_of_node(cfg->fwnode) : cfg->of_node;
> psy->supplied_to = cfg->supplied_to;
> psy->num_supplicants = cfg->num_supplicants;
> }
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index 0c9a572..b21c4bd9 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -199,6 +199,8 @@ enum power_supply_notifier_events {
> /* Run-time specific power supply configuration */
> struct power_supply_config {
> struct device_node *of_node;
> + struct fwnode_handle *fwnode;
> +
> /* Driver private data */
> void *drv_data;
Thanks,
--
heikki
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] typec: tcpm: Provide fwnode pointer as part of psy_cfg
2018-05-22 15:16 ` [PATCH 2/2] typec: tcpm: Provide fwnode pointer as part of psy_cfg Adam Thomson
2018-05-22 16:08 ` Guenter Roeck
@ 2018-05-23 6:52 ` Heikki Krogerus
1 sibling, 0 replies; 7+ messages in thread
From: Heikki Krogerus @ 2018-05-23 6:52 UTC (permalink / raw)
To: Adam Thomson
Cc: Guenter Roeck, Greg Kroah-Hartman, Sebastian Reichel, linux-usb,
linux-pm, linux-kernel, support.opensource
On Tue, May 22, 2018 at 04:16:24PM +0100, Adam Thomson wrote:
> For supply registration, provide fwnode pointer of the port device,
> via the power_supply_config structure, to allow other psy drivers
> to add us as a supplier. At present this only applies to DT
> based platforms using the 'power-supplies' DT property, but in the
> future should also work for ACPI platforms when the relevant support
> is added to the power_supply core.
>
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/tcpm.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 72996cc..0ccd2ce 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -14,6 +14,7 @@
> #include <linux/mutex.h>
> #include <linux/power_supply.h>
> #include <linux/proc_fs.h>
> +#include <linux/property.h>
> #include <linux/sched/clock.h>
> #include <linux/seq_file.h>
> #include <linux/slab.h>
> @@ -4500,6 +4501,7 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
> char *psy_name;
>
> psy_cfg.drv_data = port;
> + psy_cfg.fwnode = dev_fwnode(port->dev);
> psy_name = devm_kzalloc(port->dev, psy_name_len, GFP_KERNEL);
> if (!psy_name)
> return -ENOMEM;
Thanks,
--
heikki
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-05-23 6:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-22 15:16 [PATCH 0/2] typec: tcpm: Populate fwnode for use in power_supply core Adam Thomson
2018-05-22 15:16 ` [PATCH 1/2] power: supply: Add fwnode pointer to power_supply_config struct Adam Thomson
2018-05-22 16:15 ` Sebastian Reichel
2018-05-23 6:48 ` Heikki Krogerus
2018-05-22 15:16 ` [PATCH 2/2] typec: tcpm: Provide fwnode pointer as part of psy_cfg Adam Thomson
2018-05-22 16:08 ` Guenter Roeck
2018-05-23 6:52 ` Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).