Re: [try#1 PATCH 5/7] omap4: panda: add smsc95xx regulator and reset dependent on root hub

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/30/2012 01:57 AM, the mail apparently from Alan Stern included:
On Thu, 29 Nov 2012, Andy Green wrote:

However I think what you're saying about binding to hub power is good.
The hub ports are not devices, but it would be possible to bind an asset
array to them and make the pre- and post- code functions.

In the 3.6 kernel, hub ports are not devices.  In 3.7 they are -- that
is, each hub port has its own struct device.

Right, I should have seen this in hub.c before.  It's much better like that.

I think it will be possible to address objections around the "pathiness"
by being able to seed the path match with a platform_device pointer
(there exists in the board file time a platform_device for ehci-omap.0
...) and just matching the remainder on a single usb device's name, like
"*-1.1-1".

Can you think of a way to do this without checking for a match every
time a new device is registered?  For instance, in this case it would
be preferable to do this match only for descendants of ehci-omap.0.  To
match the port device, the string would have to be something like
"*-0:1.0/port2".

Yes. How about adding a third callback to struct device_asset, along the lines of

	int (*pre_child_register)(struct device *child);

then, in register_device() we add code that before we get down to it, we walk up the new device's parents calling ->pre_child_register() on any assets the parents may have. In the typical case that's a rapid NOP once per device registration.

However... if we had arranged back at boot time that the ehci-omap.0 struct device had an asset with only pre_device_register callback set, we can use that asset's .name for the right-justified child device name we are looking for like "-0:1.0/port2", and its .asset member to point to another asset table the pre_child_register callback will attach to the child device if the name matches. So in the board file:

	struct device_asset ehci_omap0_smsc_hub_port_assets[] = {
		/* the smsc regulator and clock assets destined for the hub port */
		{ }
	};

	/* below is attached to ehci-omap.0 like in try#1 */

	struct device_asset ehci_omap0_assets[] = {
		{
			.name = "-0:1.0/port2",
			.asset = ehci_omap0_smsc_hub_port_assets,
			.pre_child_register = device_asset_attach_to_child,
		},
		{ }
	};

In that way we can project as many stashed asset tables on to dynamically probed devices as we like from the platform_devices at boot time. Only children of the right platform devices do any checking or processing.

In fact, if the match were anchored at the end of the string, we
wouldn't need the wildcard at all -- at least, not in this case.  The
string could simply be "-0:1.0/port2".  But that's only if the match is
restricted to devices below ehci-omap.0.

It's a good idea, it won't get fooled by a hub getting plugged there which has its own port2 either, the -0:1.0 bit will have been elaborated for the subsequent hub "path" and won't match.


It may be neater to split out the device_asset callbacks to an ..._ops struct.

	struct device_asset_ops {
		int (*pre_probe)(struct device *device, struct device_asset *asset);
		void (*post_remove)(struct device *device, struct device_asset *asset);
		int (*pre_child_register)(struct device *child);
	};

	struct device_asset {
		...
		struct device_asset_ops *ops;
	};

that also lets us export and set one thing to select say regulator "handler", instead of n callbacks that must match.


Something else I think mux would be a great target for device_asset support. That way it could become normal for mux function to get set as part of the specific device instantiation, so if you know you have an 8-bit ULPI PHY that will be logically created by the platform_device, you can attach ULPI-mode mux config appropriate for your exact SoC as an asset to the platform_device.

When the device is destroyed, balls can go back to safe mode and save power, and if the balls are muxed with other things again the right mux asset can be associated with that so it switches automagically according to what you are doing. That's a lot better than forcing them once at boot which is the current method. Are there any gotchas with that?

-Andy

--
Andy Green | TI Landing Team Leader
Linaro.org │ Open source software for ARM SoCs | Follow Linaro
http://facebook.com/pages/Linaro/155974581091106 - http://twitter.com/#!/linaroorg - http://linaro.org/linaro-blog
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux