All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] reset: add support for non-DT systems
@ 2018-02-19 16:58 Bartosz Golaszewski
  2018-02-20  0:21 ` David Lechner
  0 siblings, 1 reply; 8+ messages in thread
From: Bartosz Golaszewski @ 2018-02-19 16:58 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: linux-kernel, Bartosz Golaszewski, Sekhar Nori, Kevin Hilman,
	David Lechner

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

The reset framework only supports device-tree. There are some platforms
however, which need to use it even in legacy, board-file based mode.

An example of such architecture is the DaVinci family of SoCs which
supports both device tree and legacy boot modes and we don't want to
introduce any regressions.

We're currently working on converting the platform from its hand-crafted
clock API to using the common clock framework. Part of the overhaul will
be representing the chip's power sleep controller's reset lines using
the reset framework.

This changeset extends the core reset code with new reset lookup
structures. Each lookup table contains a set of lookup entries which
allow the reset core to associate reset lines with devices (by
comparing the dev_id and con_id strings).

Machine code can register a set of reset lines using this lookup table
and concerned devices can access them using the regular reset_control
API.

The new lookup function is only called as a fallback in case the
of_node field is NULL and doesn't change anything for current users.

Tested with a dummy reset driver with several lookup entries.

An example lookup table can be found below:

static struct platform_device foobar_reset_dev = {
        .name = "foobar-reset",
};

static struct reset_lookup_entry foobar_reset_lookup_entries[] = {
        { .con_id = "foo",    id = 15 },
        { .con_id = "bar",    id = 5  },
};

static struct reset_lookup_table foobar_reset_lookup_table = {
        .dev_id = "foobar-device",
        .entries = foobar_reset_lookup_entries,
        .num_entries = ARRAY_SIZE(foobar_reset_lookup_entries),
        .dev = &foobar_reset_dev.dev,
};

Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: David Lechner <david@lechnology.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
v1 -> v2:
- renamed the new function to __reset_control_get_from_lookup()
- added a missing break; when a matching entry is found
- rearranged the code in __reset_control_get() - we can no longer get to the
  return at the bottom, so remove it and return from
  __reset_control_get_from_lookup() if __of_reset_control_get() fails
- return -ENOENT from reset_contol_get() if we can't find a matching entry,
  prevously returned -EINVAL referred to the fact that we passed a device
  without the of_node which is no longer an error condition
- add a comment about needing a sentinel in the lookup table

v2 -> v3:
- added the reset id number field to the lookup struct so that we don't need
  to rely on the array index

v3 -> v4:
- separated the driver and lookup table registration logic by adding a
  function meant to be called by machine-specific code that adds a lookup
  table to the internal list
- the correct reset controller is now found by first finding the lookup
  table associated with it, then finding the actual reset controller by
  the associated device

 drivers/reset/core.c             | 75 +++++++++++++++++++++++++++++++++++++++-
 include/linux/reset-controller.h | 32 +++++++++++++++++
 2 files changed, 106 insertions(+), 1 deletion(-)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index da4292e9de97..fc6abdaf44f2 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -23,6 +23,9 @@
 static DEFINE_MUTEX(reset_list_mutex);
 static LIST_HEAD(reset_controller_list);
 
+static DEFINE_MUTEX(reset_lookup_mutex);
+static LIST_HEAD(reset_lookup_list);
+
 /**
  * struct reset_control - a reset control
  * @rcdev: a pointer to the reset controller device
@@ -493,6 +496,76 @@ struct reset_control *__of_reset_control_get(struct device_node *node,
 }
 EXPORT_SYMBOL_GPL(__of_reset_control_get);
 
+/**
+ * reset_add_lookup_table - add a new reset lookup table
+ * @table: new reset lookup table
+ */
+void reset_add_lookup_table(struct reset_lookup_table *table)
+{
+	mutex_lock(&reset_lookup_mutex);
+	list_add_tail(&table->list, &reset_lookup_list);
+	mutex_unlock(&reset_lookup_mutex);
+}
+EXPORT_SYMBOL_GPL(reset_add_lookup_table);
+
+static struct reset_control *
+reset_control_find_device(struct device *dev, unsigned int id, bool shared)
+{
+	struct reset_controller_dev *rcdev;
+	struct reset_control *rstc = NULL;
+
+	mutex_lock(&reset_list_mutex);
+
+	list_for_each_entry(rcdev, &reset_controller_list, list) {
+		if (rcdev->dev == dev) {
+			rstc = __reset_control_get_internal(rcdev, id, shared);
+			break;
+		}
+	}
+
+	mutex_unlock(&reset_list_mutex);
+
+	return rstc;
+}
+
+static struct reset_control *
+__reset_control_get_from_lookup(struct device *dev, const char *con_id,
+				bool shared, bool optional)
+{
+	const struct reset_lookup_entry *entry;
+	const char *dev_id = dev_name(dev);
+	struct reset_control *rstc = NULL;
+	struct reset_lookup_table *table;
+	int i;
+
+	mutex_lock(&reset_lookup_mutex);
+
+	list_for_each_entry(table, &reset_lookup_list, list) {
+		if (strcmp(table->dev_id, dev_id))
+			continue;
+
+		for (i = 0; i < table->num_entries; i++) {
+			entry = &table->entries[i];
+
+			if ((!con_id && !entry->con_id) ||
+			    !strcmp(con_id, entry->con_id)) {
+				rstc = reset_control_find_device(table->dev,
+								 entry->id,
+								 shared);
+				goto out;
+			}
+		}
+	}
+
+out:
+	mutex_unlock(&reset_lookup_mutex);
+
+	if (!rstc)
+		return optional ? NULL : ERR_PTR(-ENOENT);
+
+	return rstc;
+}
+
 struct reset_control *__reset_control_get(struct device *dev, const char *id,
 					  int index, bool shared, bool optional)
 {
@@ -500,7 +573,7 @@ struct reset_control *__reset_control_get(struct device *dev, const char *id,
 		return __of_reset_control_get(dev->of_node, id, index, shared,
 					      optional);
 
-	return optional ? NULL : ERR_PTR(-EINVAL);
+	return __reset_control_get_from_lookup(dev, id, shared, optional);
 }
 EXPORT_SYMBOL_GPL(__reset_control_get);
 
diff --git a/include/linux/reset-controller.h b/include/linux/reset-controller.h
index adb88f8cefbc..b92090b177b7 100644
--- a/include/linux/reset-controller.h
+++ b/include/linux/reset-controller.h
@@ -22,6 +22,36 @@ struct reset_control_ops {
 	int (*status)(struct reset_controller_dev *rcdev, unsigned long id);
 };
 
+/**
+ * struct reset_lookup_entry - a single entry in a reset lookup table
+ *
+ * @con_id: name of the reset line (can be NULL)
+ * @id: ID of the reset controller in the reset controller device
+ */
+struct reset_lookup_entry {
+	const char *con_id;
+	unsigned long id;
+};
+
+/**
+ * struct reset_lookup_table - reset controller lookup table
+ *
+ * @list: internal list of lookup tables
+ * @dev: reset controller device associated with this table
+ * @dev_id: name of the device associated with the resets in this table
+ * @entries: list of reset lookup entries
+ * @num_entries: number of reset lookup entries
+ */
+struct reset_lookup_table {
+	struct list_head list;
+	struct device *dev;
+	const char *dev_id;
+	struct reset_lookup_entry *entries;
+	size_t num_entries;
+};
+
+void reset_add_lookup_table(struct reset_lookup_table *table);
+
 struct module;
 struct device_node;
 struct of_phandle_args;
@@ -34,6 +64,7 @@ struct of_phandle_args;
  * @list: internal list of reset controller devices
  * @reset_control_head: head of internal list of requested reset controls
  * @of_node: corresponding device tree node as phandle target
+ * @dev: corresponding device (as fallback when not using OF)
  * @of_reset_n_cells: number of cells in reset line specifiers
  * @of_xlate: translation function to translate from specifier as found in the
  *            device tree to id as given to the reset control ops
@@ -45,6 +76,7 @@ struct reset_controller_dev {
 	struct list_head list;
 	struct list_head reset_control_head;
 	struct device_node *of_node;
+	struct device *dev;
 	int of_reset_n_cells;
 	int (*of_xlate)(struct reset_controller_dev *rcdev,
 			const struct of_phandle_args *reset_spec);
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] reset: add support for non-DT systems
  2018-02-19 16:58 [PATCH v4] reset: add support for non-DT systems Bartosz Golaszewski
@ 2018-02-20  0:21 ` David Lechner
  2018-02-20 10:39   ` Philipp Zabel
  0 siblings, 1 reply; 8+ messages in thread
From: David Lechner @ 2018-02-20  0:21 UTC (permalink / raw)
  To: Bartosz Golaszewski, Philipp Zabel
  Cc: linux-kernel, Bartosz Golaszewski, Sekhar Nori, Kevin Hilman

On 02/19/2018 10:58 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> The reset framework only supports device-tree. There are some platforms
> however, which need to use it even in legacy, board-file based mode.
> 
> An example of such architecture is the DaVinci family of SoCs which
> supports both device tree and legacy boot modes and we don't want to
> introduce any regressions.
> 
> We're currently working on converting the platform from its hand-crafted
> clock API to using the common clock framework. Part of the overhaul will
> be representing the chip's power sleep controller's reset lines using
> the reset framework.
> 
> This changeset extends the core reset code with new reset lookup
> structures. Each lookup table contains a set of lookup entries which
> allow the reset core to associate reset lines with devices (by
> comparing the dev_id and con_id strings).
> 
> Machine code can register a set of reset lines using this lookup table
> and concerned devices can access them using the regular reset_control
> API.
> 
> The new lookup function is only called as a fallback in case the
> of_node field is NULL and doesn't change anything for current users.
> 
> Tested with a dummy reset driver with several lookup entries.
> 
> An example lookup table can be found below:
> 
> static struct platform_device foobar_reset_dev = {
>          .name = "foobar-reset",
> };
> 
> static struct reset_lookup_entry foobar_reset_lookup_entries[] = {
>          { .con_id = "foo",    id = 15 },
>          { .con_id = "bar",    id = 5  },
> };
> 
> static struct reset_lookup_table foobar_reset_lookup_table = {
>          .dev_id = "foobar-device",
>          .entries = foobar_reset_lookup_entries,
>          .num_entries = ARRAY_SIZE(foobar_reset_lookup_entries),
>          .dev = &foobar_reset_dev.dev,
> };
> 

This seems like a lot of boilerplate to register a lookup. Can we have
something like phy_create_lookup() instead where there is just a single
function call to register a single lookup? This will be much easier to
use in the davinci PSC driver.

void reset_add_lookup(struct reset_controller_dev *rdev, int index,
		      const char *dev_id, const char *con_id);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] reset: add support for non-DT systems
  2018-02-20  0:21 ` David Lechner
@ 2018-02-20 10:39   ` Philipp Zabel
  2018-02-20 16:40     ` David Lechner
  0 siblings, 1 reply; 8+ messages in thread
From: Philipp Zabel @ 2018-02-20 10:39 UTC (permalink / raw)
  To: David Lechner, Bartosz Golaszewski
  Cc: linux-kernel, Bartosz Golaszewski, Sekhar Nori, Kevin Hilman

Hi Bartosz, David,

On Mon, 2018-02-19 at 18:21 -0600, David Lechner wrote:
> On 02/19/2018 10:58 AM, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > 
> > The reset framework only supports device-tree. There are some platforms
> > however, which need to use it even in legacy, board-file based mode.
> > 
> > An example of such architecture is the DaVinci family of SoCs which
> > supports both device tree and legacy boot modes and we don't want to
> > introduce any regressions.
> > 
> > We're currently working on converting the platform from its hand-crafted
> > clock API to using the common clock framework. Part of the overhaul will
> > be representing the chip's power sleep controller's reset lines using
> > the reset framework.
> > 
> > This changeset extends the core reset code with new reset lookup
> > structures. Each lookup table contains a set of lookup entries which
> > allow the reset core to associate reset lines with devices (by
> > comparing the dev_id and con_id strings).
> > 
> > Machine code can register a set of reset lines using this lookup table
> > and concerned devices can access them using the regular reset_control
> > API.
> > 
> > The new lookup function is only called as a fallback in case the
> > of_node field is NULL and doesn't change anything for current users.
> > 
> > Tested with a dummy reset driver with several lookup entries.
> > 
> > An example lookup table can be found below:
> > 
> > static struct platform_device foobar_reset_dev = {
> >          .name = "foobar-reset",
> > };
> > 
> > static struct reset_lookup_entry foobar_reset_lookup_entries[] = {
> >          { .con_id = "foo",    id = 15 },
> >          { .con_id = "bar",    id = 5  },
> > };
> > 
> > static struct reset_lookup_table foobar_reset_lookup_table = {
> >          .dev_id = "foobar-device",
> >          .entries = foobar_reset_lookup_entries,
> >          .num_entries = ARRAY_SIZE(foobar_reset_lookup_entries),
> >          .dev = &foobar_reset_dev.dev,
> > };
> > 
> 
> This seems like a lot of boilerplate to register a lookup.

This could be shortened a bit by following the gpiod lookup model,
adding a RESET_LOOKUP macro and making the array NULL terminated:

#define RESET_LOOKUP(reset_dev_id, idx, con_id) /*...*/

static struct reset_lookup_table foobar_reset_lookup_table = {
	.dev_id = "foobar-device",
	.entries = {
		RESET_LOOKUP("foobar-reset.0", 15, "foo"),
		RESET_LOOKUP("foobar-reset.0", 5, "bar"),
		{ },
	},
};

	/*...*/
	reset_add_lookup_table(&foobar_reset_lookup_table);

>  Can we have
> something like phy_create_lookup() instead where there is just a single
> function call to register a single lookup? This will be much easier to
> use in the davinci PSC driver.
> 
> void reset_add_lookup(struct reset_controller_dev *rdev, int index,
> 		      const char *dev_id, const char *con_id);

In your case the platform code that adds the lookup may be identical to
the code that registers the struct reset_controller_dev, but that
doesn't have to be the case. I'm not sure how that is supposed to work
for the phy framework (I see no platform code adding phy lookups, only
drivers).

My point was that if the reset controller is registered by a separate
driver, the platform code may not have access to the struct
reset_controller_dev, or even the struct platform_device. I like that
the gpiod lookups can match by dev_id of the gpio chip.

regards
Philipp

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] reset: add support for non-DT systems
  2018-02-20 10:39   ` Philipp Zabel
@ 2018-02-20 16:40     ` David Lechner
  2018-02-22 11:34       ` Philipp Zabel
  0 siblings, 1 reply; 8+ messages in thread
From: David Lechner @ 2018-02-20 16:40 UTC (permalink / raw)
  To: Philipp Zabel, Bartosz Golaszewski
  Cc: linux-kernel, Bartosz Golaszewski, Sekhar Nori, Kevin Hilman

On 02/20/2018 04:39 AM, Philipp Zabel wrote:
> Hi Bartosz, David,
> 
> On Mon, 2018-02-19 at 18:21 -0600, David Lechner wrote:
>> On 02/19/2018 10:58 AM, Bartosz Golaszewski wrote:
>>> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>>>
>>> The reset framework only supports device-tree. There are some platforms
>>> however, which need to use it even in legacy, board-file based mode.
>>>
>>> An example of such architecture is the DaVinci family of SoCs which
>>> supports both device tree and legacy boot modes and we don't want to
>>> introduce any regressions.
>>>
>>> We're currently working on converting the platform from its hand-crafted
>>> clock API to using the common clock framework. Part of the overhaul will
>>> be representing the chip's power sleep controller's reset lines using
>>> the reset framework.
>>>
>>> This changeset extends the core reset code with new reset lookup
>>> structures. Each lookup table contains a set of lookup entries which
>>> allow the reset core to associate reset lines with devices (by
>>> comparing the dev_id and con_id strings).
>>>
>>> Machine code can register a set of reset lines using this lookup table
>>> and concerned devices can access them using the regular reset_control
>>> API.
>>>
>>> The new lookup function is only called as a fallback in case the
>>> of_node field is NULL and doesn't change anything for current users.
>>>
>>> Tested with a dummy reset driver with several lookup entries.
>>>
>>> An example lookup table can be found below:
>>>
>>> static struct platform_device foobar_reset_dev = {
>>>           .name = "foobar-reset",
>>> };
>>>
>>> static struct reset_lookup_entry foobar_reset_lookup_entries[] = {
>>>           { .con_id = "foo",    id = 15 },
>>>           { .con_id = "bar",    id = 5  },
>>> };
>>>
>>> static struct reset_lookup_table foobar_reset_lookup_table = {
>>>           .dev_id = "foobar-device",
>>>           .entries = foobar_reset_lookup_entries,
>>>           .num_entries = ARRAY_SIZE(foobar_reset_lookup_entries),
>>>           .dev = &foobar_reset_dev.dev,
>>> };
>>>
>>
>> This seems like a lot of boilerplate to register a lookup.
> 
> This could be shortened a bit by following the gpiod lookup model,
> adding a RESET_LOOKUP macro and making the array NULL terminated:
> 
> #define RESET_LOOKUP(reset_dev_id, idx, con_id) /*...*/
> 
> static struct reset_lookup_table foobar_reset_lookup_table = {
> 	.dev_id = "foobar-device",
> 	.entries = {
> 		RESET_LOOKUP("foobar-reset.0", 15, "foo"),
> 		RESET_LOOKUP("foobar-reset.0", 5, "bar"),
> 		{ },
> 	},
> };
> 
> 	/*...*/
> 	reset_add_lookup_table(&foobar_reset_lookup_table);
> 
>>   Can we have
>> something like phy_create_lookup() instead where there is just a single
>> function call to register a single lookup? This will be much easier to
>> use in the davinci PSC driver.
>>
>> void reset_add_lookup(struct reset_controller_dev *rdev, int index,
>> 		      const char *dev_id, const char *con_id);
> 
> In your case the platform code that adds the lookup may be identical to
> the code that registers the struct reset_controller_dev, but that
> doesn't have to be the case. I'm not sure how that is supposed to work
> for the phy framework (I see no platform code adding phy lookups, only
> drivers).
> 
> My point was that if the reset controller is registered by a separate
> driver, the platform code may not have access to the struct
> reset_controller_dev, or even the struct platform_device. I like that
> the gpiod lookups can match by dev_id of the gpio chip.
> 
> regards
> Philipp
> 

In our use case, we would be adding the lookup in the driver rather than
in the platform code, which is why I am suggesting doing it like the phy
framework.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] reset: add support for non-DT systems
  2018-02-20 16:40     ` David Lechner
@ 2018-02-22 11:34       ` Philipp Zabel
  2018-02-22 13:32         ` Bartosz Golaszewski
  2018-02-22 16:44         ` David Lechner
  0 siblings, 2 replies; 8+ messages in thread
From: Philipp Zabel @ 2018-02-22 11:34 UTC (permalink / raw)
  To: David Lechner, Bartosz Golaszewski
  Cc: linux-kernel, Bartosz Golaszewski, Sekhar Nori, Kevin Hilman

On Tue, 2018-02-20 at 10:40 -0600, David Lechner wrote:
[...]
> > In your case the platform code that adds the lookup may be identical to
> > the code that registers the struct reset_controller_dev, but that
> > doesn't have to be the case. I'm not sure how that is supposed to work
> > for the phy framework (I see no platform code adding phy lookups, only
> > drivers).
> > 
> In our use case, we would be adding the lookup in the driver rather than
> in the platform code, which is why I am suggesting doing it like the phy
> framework.

Shouldn't it be the job of the platform code to describe the connections
between reset controller and peripheral module reset
inputs?

regards
Philipp

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] reset: add support for non-DT systems
  2018-02-22 11:34       ` Philipp Zabel
@ 2018-02-22 13:32         ` Bartosz Golaszewski
  2018-02-22 16:44         ` David Lechner
  1 sibling, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2018-02-22 13:32 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: David Lechner, Bartosz Golaszewski, LKML, Sekhar Nori, Kevin Hilman

2018-02-22 12:34 GMT+01:00 Philipp Zabel <p.zabel@pengutronix.de>:
> On Tue, 2018-02-20 at 10:40 -0600, David Lechner wrote:
> [...]
>> > In your case the platform code that adds the lookup may be identical to
>> > the code that registers the struct reset_controller_dev, but that
>> > doesn't have to be the case. I'm not sure how that is supposed to work
>> > for the phy framework (I see no platform code adding phy lookups, only
>> > drivers).
>> >
>> In our use case, we would be adding the lookup in the driver rather than
>> in the platform code, which is why I am suggesting doing it like the phy
>> framework.
>
> Shouldn't it be the job of the platform code to describe the connections
> between reset controller and peripheral module reset
> inputs?
>
> regards
> Philipp

Am I right to understand that it's ok for drivers to know about the
available reset lines on the platform, it's just the associated
between these lines and concerned devices that should be done in
platform code?

Bart

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] reset: add support for non-DT systems
  2018-02-22 11:34       ` Philipp Zabel
  2018-02-22 13:32         ` Bartosz Golaszewski
@ 2018-02-22 16:44         ` David Lechner
  2018-02-23 11:41           ` Bartosz Golaszewski
  1 sibling, 1 reply; 8+ messages in thread
From: David Lechner @ 2018-02-22 16:44 UTC (permalink / raw)
  To: Philipp Zabel, Bartosz Golaszewski
  Cc: linux-kernel, Bartosz Golaszewski, Sekhar Nori, Kevin Hilman

On 02/22/2018 05:34 AM, Philipp Zabel wrote:
> On Tue, 2018-02-20 at 10:40 -0600, David Lechner wrote:
> [...]
>>> In your case the platform code that adds the lookup may be identical to
>>> the code that registers the struct reset_controller_dev, but that
>>> doesn't have to be the case. I'm not sure how that is supposed to work
>>> for the phy framework (I see no platform code adding phy lookups, only
>>> drivers).
>>>
>> In our use case, we would be adding the lookup in the driver rather than
>> in the platform code, which is why I am suggesting doing it like the phy
>> framework.
> 
> Shouldn't it be the job of the platform code to describe the connections
> between reset controller and peripheral module reset
> inputs?


I guess that depends on who you ask. There are many clock driver that
register clkdev lookups in drivers/clk/, so that is what we have done
with the clock driver we are working on. The clock device is also the
reset controller, so it makes sense to me to register the reset lookup
in the same place that we are registering the clkdev lookup.

We have a platform_device_id for each possible configuration, so that
it works very much like the device tree compatible string. You register
a platform device in the board file with the proper name and the driver
takes care of the reset because it knows which connections there are
based on the device name.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4] reset: add support for non-DT systems
  2018-02-22 16:44         ` David Lechner
@ 2018-02-23 11:41           ` Bartosz Golaszewski
  0 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2018-02-23 11:41 UTC (permalink / raw)
  To: David Lechner
  Cc: Philipp Zabel, Linux Kernel Mailing List, Bartosz Golaszewski,
	Sekhar Nori, Kevin Hilman

2018-02-22 17:44 GMT+01:00 David Lechner <david@lechnology.com>:
> On 02/22/2018 05:34 AM, Philipp Zabel wrote:
>>
>> On Tue, 2018-02-20 at 10:40 -0600, David Lechner wrote:
>> [...]
>>>>
>>>> In your case the platform code that adds the lookup may be identical to
>>>> the code that registers the struct reset_controller_dev, but that
>>>> doesn't have to be the case. I'm not sure how that is supposed to work
>>>> for the phy framework (I see no platform code adding phy lookups, only
>>>> drivers).
>>>>
>>> In our use case, we would be adding the lookup in the driver rather than
>>> in the platform code, which is why I am suggesting doing it like the phy
>>> framework.
>>
>>
>> Shouldn't it be the job of the platform code to describe the connections
>> between reset controller and peripheral module reset
>> inputs?
>
>
>
> I guess that depends on who you ask. There are many clock driver that
> register clkdev lookups in drivers/clk/, so that is what we have done
> with the clock driver we are working on. The clock device is also the
> reset controller, so it makes sense to me to register the reset lookup
> in the same place that we are registering the clkdev lookup.
>
> We have a platform_device_id for each possible configuration, so that
> it works very much like the device tree compatible string. You register
> a platform device in the board file with the proper name and the driver
> takes care of the reset because it knows which connections there are
> based on the device name.

I sent another attempt. Since the in-progress psc driver has all the
clocks in the driver code, it makes sense to do the same for resets.

Bart

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-02-23 11:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-19 16:58 [PATCH v4] reset: add support for non-DT systems Bartosz Golaszewski
2018-02-20  0:21 ` David Lechner
2018-02-20 10:39   ` Philipp Zabel
2018-02-20 16:40     ` David Lechner
2018-02-22 11:34       ` Philipp Zabel
2018-02-22 13:32         ` Bartosz Golaszewski
2018-02-22 16:44         ` David Lechner
2018-02-23 11:41           ` Bartosz Golaszewski

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.