Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 On 07/30/2013 04:33 PM, Felipe Balbi wrote: > let's try not to add any new TI-specific DT bindings, can you > figure that out by reading some revision register ? Or perhaps by > using different compatible strings ? I would suggest to use a different binding. But I'm currently trying to come up with something for am335x with a device reference? Sebastian -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.14 (GNU/Linux) iQIcBAEBCAAGBQJR99AZAAoJEHuW6BYqjPXRf5AP/jcMFUstlqqujRppC2gMsqh6 +xlpwh5hCHJPxQizwkG8kWW9XGMIMPmqODqoYwA9dFI3a5VgVVTRUkhnHEXlAt9A 8X0Sl+mdKx0XwvjxjRDPUEYqvpDFAPYxgnwvxEfjtnDgQs5ikxFj4zaMonAj5oK0 s7XnOImJmdoHbFfvR5Cx10zmfa0BjQETqk5bt/j8+8jnv86cZk8fEGE8XYoUnhFw BsEZgfSZH/pV6s339gTs+x4+zW0luJIhJdtQmh5Ylo+xt/3TYAmDuZ0v88A6gFV+ MZjJLh2L9Sr6g0Pl/Rk5aMZhe5GSSrZYuu4Vltpz2xF1SjRRqg6ykmw6sqnme2uj BWwq5qNG5EFPtyhZCupTZ/z388kKOhC54kbFwJW7Duv9TkDUOctVuUbehEN4Pu/u HljW3FoYvvB/7EOXJhBcG6qy+ClS7mKkJJHeavnzbtzeg2jO1ZSKV1S/bJfpY4F6 ualEKdC+A+UXYNHSnSkbdJPAfIQw9BOhdD3nszdzrB+0xUU1ul2V3Zdf0xKsUVPj 8qkK9IuHum/pUfUEK/3C/igOhtag24LOhiGu1MG8Axe4FdmiTixhnV4DZzGyAMcm 8Br/gtKVCuoU89y0mYhsAA5o+3e6YKE7lPQVULtrZO7/+wbOTrEaukvwCMB/NngL +qNzg8WzrRHCAQnSKni9 =712g -END PGP SIGNATURE- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
On Tue, Jul 30, 2013 at 07:54:55PM +0530, George Cherian wrote: > On 7/30/2013 2:23 PM, Sebastian Andrzej Siewior wrote: > >On 07/30/2013 07:19 AM, George Cherian wrote: > >>>So from what I see now, it is most likely the easiest thing to just add > >>>that wakeup to the phy driver I posted. Do you agree? > >>The whole idea of writing a seperate phy driver was to use the generic > >>phy framework > >>and most of the am devices have the same phy (eg am335x, am437x). > >>Now since the register is shared in am335x for phy_wkup (Not in the case > >>of am437x) > >>how are you planning to map it. I feel if omap_control_usb can delegate > >>the writes > >>to phy_wkup, phy_on and phy_off, it makes the life simpler. > >that omap-control driver looks a little strange. It has a compatible > >field saying ti,omap-control-usb and then it requires additionally a > >ti,type property which should have been avoided. > > ti,type property is to differentiate between usb2 and usb3 phy for a > single soc. > for eg: OMAP5 has both usb2 and usb3 phy let's try not to add any new TI-specific DT bindings, can you figure that out by reading some revision register ? Or perhaps by using different compatible strings ? -- balbi signature.asc Description: Digital signature
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
On 7/30/2013 2:23 PM, Sebastian Andrzej Siewior wrote: On 07/30/2013 07:19 AM, George Cherian wrote: So from what I see now, it is most likely the easiest thing to just add that wakeup to the phy driver I posted. Do you agree? The whole idea of writing a seperate phy driver was to use the generic phy framework and most of the am devices have the same phy (eg am335x, am437x). Now since the register is shared in am335x for phy_wkup (Not in the case of am437x) how are you planning to map it. I feel if omap_control_usb can delegate the writes to phy_wkup, phy_on and phy_off, it makes the life simpler. that omap-control driver looks a little strange. It has a compatible field saying ti,omap-control-usb and then it requires additionally a ti,type property which should have been avoided. ti,type property is to differentiate between usb2 and usb3 phy for a single soc. for eg: OMAP5 has both usb2 and usb3 phy -- -George -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
On 07/30/2013 07:19 AM, George Cherian wrote: >> So from what I see now, it is most likely the easiest thing to just add >> that wakeup to the phy driver I posted. Do you agree? > > The whole idea of writing a seperate phy driver was to use the generic > phy framework > and most of the am devices have the same phy (eg am335x, am437x). > Now since the register is shared in am335x for phy_wkup (Not in the case > of am437x) > how are you planning to map it. I feel if omap_control_usb can delegate > the writes > to phy_wkup, phy_on and phy_off, it makes the life simpler. that omap-control driver looks a little strange. It has a compatible field saying ti,omap-control-usb and then it requires additionally a ti,type property which should have been avoided. But back to the initial problem. I don't really like the idea of touching in the control-module registers but others do it as well. So the idea of a control driver doesn't sound that bad. - an am335x-reset device - a phy driver with a reference to that reset device. - non-standard phy calls for power & wak eup on/off. Let me think about it. > > Thoughts??? I think I buy it but give me a bit… > Sebastian -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
On 07/30/2013 07:19 AM, George Cherian wrote: So from what I see now, it is most likely the easiest thing to just add that wakeup to the phy driver I posted. Do you agree? The whole idea of writing a seperate phy driver was to use the generic phy framework and most of the am devices have the same phy (eg am335x, am437x). Now since the register is shared in am335x for phy_wkup (Not in the case of am437x) how are you planning to map it. I feel if omap_control_usb can delegate the writes to phy_wkup, phy_on and phy_off, it makes the life simpler. that omap-control driver looks a little strange. It has a compatible field saying ti,omap-control-usb and then it requires additionally a ti,type property which should have been avoided. But back to the initial problem. I don't really like the idea of touching in the control-module registers but others do it as well. So the idea of a control driver doesn't sound that bad. - an am335x-reset device - a phy driver with a reference to that reset device. - non-standard phy calls for power wak eup on/off. Let me think about it. Thoughts??? I think I buy it but give me a bit… Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
On 7/30/2013 2:23 PM, Sebastian Andrzej Siewior wrote: On 07/30/2013 07:19 AM, George Cherian wrote: So from what I see now, it is most likely the easiest thing to just add that wakeup to the phy driver I posted. Do you agree? The whole idea of writing a seperate phy driver was to use the generic phy framework and most of the am devices have the same phy (eg am335x, am437x). Now since the register is shared in am335x for phy_wkup (Not in the case of am437x) how are you planning to map it. I feel if omap_control_usb can delegate the writes to phy_wkup, phy_on and phy_off, it makes the life simpler. that omap-control driver looks a little strange. It has a compatible field saying ti,omap-control-usb and then it requires additionally a ti,type property which should have been avoided. ti,type property is to differentiate between usb2 and usb3 phy for a single soc. for eg: OMAP5 has both usb2 and usb3 phy -- -George -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
On Tue, Jul 30, 2013 at 07:54:55PM +0530, George Cherian wrote: On 7/30/2013 2:23 PM, Sebastian Andrzej Siewior wrote: On 07/30/2013 07:19 AM, George Cherian wrote: So from what I see now, it is most likely the easiest thing to just add that wakeup to the phy driver I posted. Do you agree? The whole idea of writing a seperate phy driver was to use the generic phy framework and most of the am devices have the same phy (eg am335x, am437x). Now since the register is shared in am335x for phy_wkup (Not in the case of am437x) how are you planning to map it. I feel if omap_control_usb can delegate the writes to phy_wkup, phy_on and phy_off, it makes the life simpler. that omap-control driver looks a little strange. It has a compatible field saying ti,omap-control-usb and then it requires additionally a ti,type property which should have been avoided. ti,type property is to differentiate between usb2 and usb3 phy for a single soc. for eg: OMAP5 has both usb2 and usb3 phy let's try not to add any new TI-specific DT bindings, can you figure that out by reading some revision register ? Or perhaps by using different compatible strings ? -- balbi signature.asc Description: Digital signature
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 On 07/30/2013 04:33 PM, Felipe Balbi wrote: let's try not to add any new TI-specific DT bindings, can you figure that out by reading some revision register ? Or perhaps by using different compatible strings ? I would suggest to use a different binding. But I'm currently trying to come up with something for am335x with a device reference? Sebastian -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.14 (GNU/Linux) iQIcBAEBCAAGBQJR99AZAAoJEHuW6BYqjPXRf5AP/jcMFUstlqqujRppC2gMsqh6 +xlpwh5hCHJPxQizwkG8kWW9XGMIMPmqODqoYwA9dFI3a5VgVVTRUkhnHEXlAt9A 8X0Sl+mdKx0XwvjxjRDPUEYqvpDFAPYxgnwvxEfjtnDgQs5ikxFj4zaMonAj5oK0 s7XnOImJmdoHbFfvR5Cx10zmfa0BjQETqk5bt/j8+8jnv86cZk8fEGE8XYoUnhFw BsEZgfSZH/pV6s339gTs+x4+zW0luJIhJdtQmh5Ylo+xt/3TYAmDuZ0v88A6gFV+ MZjJLh2L9Sr6g0Pl/Rk5aMZhe5GSSrZYuu4Vltpz2xF1SjRRqg6ykmw6sqnme2uj BWwq5qNG5EFPtyhZCupTZ/z388kKOhC54kbFwJW7Duv9TkDUOctVuUbehEN4Pu/u HljW3FoYvvB/7EOXJhBcG6qy+ClS7mKkJJHeavnzbtzeg2jO1ZSKV1S/bJfpY4F6 ualEKdC+A+UXYNHSnSkbdJPAfIQw9BOhdD3nszdzrB+0xUU1ul2V3Zdf0xKsUVPj 8qkK9IuHum/pUfUEK/3C/igOhtag24LOhiGu1MG8Axe4FdmiTixhnV4DZzGyAMcm 8Br/gtKVCuoU89y0mYhsAA5o+3e6YKE7lPQVULtrZO7/+wbOTrEaukvwCMB/NngL +qNzg8WzrRHCAQnSKni9 =712g -END PGP SIGNATURE- -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
On 7/29/2013 8:47 PM, Sebastian Andrzej Siewior wrote: * George Cherian | 2013-07-19 18:04:35 [+0530]: Adds phy driver support for am33xx platform, the host/device peripheral controller shall get this phy object to control the phy operations. If you rebase this on-top of the two instances patches I've sent earlier then you can bury patch 3 and 4, right? Yes True. I posted it for completeness. I don't like very much the way you obtain the phy id: + of_property_read_u32(np, "id", >id); with the .dts changes I made you should able to use of_alias_get_id() instead. Let me look what you have additionaly: - usbotg_fck Is this really required? I have the phy as a child of the "main" device which has a hwmod property which is associated with this clock. So pm enable/ disable should also enable this clock if possible, right? - device wakeup via omap_control_am335x_phy_wkup() Now. that is one thing that the simple phy driver is missing. If you call a magic function for this to happen than I don't have to worry about the missing memory space for this function. So from what I see now, it is most likely the easiest thing to just add that wakeup to the phy driver I posted. Do you agree? The whole idea of writing a seperate phy driver was to use the generic phy framework and most of the am devices have the same phy (eg am335x, am437x). Now since the register is shared in am335x for phy_wkup (Not in the case of am437x) how are you planning to map it. I feel if omap_control_usb can delegate the writes to phy_wkup, phy_on and phy_off, it makes the life simpler. Thoughts??? If so we need to figure out where the memory for the wakeup register is comming from. We need also to ensure that both phys can not write at the same time. A look would be nice. Signed-off-by: George Cherian Sebastian -- -George -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
* George Cherian | 2013-07-19 18:04:35 [+0530]: >Adds phy driver support for am33xx platform, the host/device >peripheral controller shall get this phy object to control the phy >operations. If you rebase this on-top of the two instances patches I've sent earlier then you can bury patch 3 and 4, right? I don't like very much the way you obtain the phy id: >+ of_property_read_u32(np, "id", >id); with the .dts changes I made you should able to use of_alias_get_id() instead. Let me look what you have additionaly: - usbotg_fck Is this really required? I have the phy as a child of the "main" device which has a hwmod property which is associated with this clock. So pm enable/ disable should also enable this clock if possible, right? - device wakeup via omap_control_am335x_phy_wkup() Now. that is one thing that the simple phy driver is missing. If you call a magic function for this to happen than I don't have to worry about the missing memory space for this function. So from what I see now, it is most likely the easiest thing to just add that wakeup to the phy driver I posted. Do you agree? If so we need to figure out where the memory for the wakeup register is comming from. We need also to ensure that both phys can not write at the same time. A look would be nice. >Signed-off-by: George Cherian Sebastian -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
* George Cherian | 2013-07-19 18:04:35 [+0530]: Adds phy driver support for am33xx platform, the host/device peripheral controller shall get this phy object to control the phy operations. If you rebase this on-top of the two instances patches I've sent earlier then you can bury patch 3 and 4, right? I don't like very much the way you obtain the phy id: + of_property_read_u32(np, id, phy-id); with the .dts changes I made you should able to use of_alias_get_id() instead. Let me look what you have additionaly: - usbotg_fck Is this really required? I have the phy as a child of the main device which has a hwmod property which is associated with this clock. So pm enable/ disable should also enable this clock if possible, right? - device wakeup via omap_control_am335x_phy_wkup() Now. that is one thing that the simple phy driver is missing. If you call a magic function for this to happen than I don't have to worry about the missing memory space for this function. So from what I see now, it is most likely the easiest thing to just add that wakeup to the phy driver I posted. Do you agree? If so we need to figure out where the memory for the wakeup register is comming from. We need also to ensure that both phys can not write at the same time. A look would be nice. Signed-off-by: George Cherian george.cher...@ti.com Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
On 7/29/2013 8:47 PM, Sebastian Andrzej Siewior wrote: * George Cherian | 2013-07-19 18:04:35 [+0530]: Adds phy driver support for am33xx platform, the host/device peripheral controller shall get this phy object to control the phy operations. If you rebase this on-top of the two instances patches I've sent earlier then you can bury patch 3 and 4, right? Yes True. I posted it for completeness. I don't like very much the way you obtain the phy id: + of_property_read_u32(np, id, phy-id); with the .dts changes I made you should able to use of_alias_get_id() instead. Let me look what you have additionaly: - usbotg_fck Is this really required? I have the phy as a child of the main device which has a hwmod property which is associated with this clock. So pm enable/ disable should also enable this clock if possible, right? - device wakeup via omap_control_am335x_phy_wkup() Now. that is one thing that the simple phy driver is missing. If you call a magic function for this to happen than I don't have to worry about the missing memory space for this function. So from what I see now, it is most likely the easiest thing to just add that wakeup to the phy driver I posted. Do you agree? The whole idea of writing a seperate phy driver was to use the generic phy framework and most of the am devices have the same phy (eg am335x, am437x). Now since the register is shared in am335x for phy_wkup (Not in the case of am437x) how are you planning to map it. I feel if omap_control_usb can delegate the writes to phy_wkup, phy_on and phy_off, it makes the life simpler. Thoughts??? If so we need to figure out where the memory for the wakeup register is comming from. We need also to ensure that both phys can not write at the same time. A look would be nice. Signed-off-by: George Cherian george.cher...@ti.com Sebastian -- -George -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
Hi, On Friday 19 July 2013 06:04 PM, George Cherian wrote: > Adds phy driver support for am33xx platform, the host/device > peripheral controller shall get this phy object to control the phy > operations. > > Signed-off-by: George Cherian > --- > drivers/phy/Kconfig | 12 +++ > drivers/phy/Makefile | 1 + > drivers/phy/phy-am-usb.c | 222 > +++ > 3 files changed, 235 insertions(+) > create mode 100644 drivers/phy/phy-am-usb.c > > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig > index 5f85909..55087ab 100644 > --- a/drivers/phy/Kconfig > +++ b/drivers/phy/Kconfig > @@ -11,3 +11,15 @@ menuconfig GENERIC_PHY > devices present in the kernel. This layer will have the generic > API by which phy drivers can create PHY using the phy framework and > phy users can obtain reference to the PHY. > +if GENERIC_PHY Greg has some comments about the generic PHY framework. So instead of having like this, you might have to select GENERIC_PHY in the Kconfig of your phy driver. > + > +config PHY_AM_USB > + tristate "AM USB2 PHY Driver" > + depends on SOC_AM33XX > + help > + Enable this to support the transceiver that is part of SOC. This > + phy supports all LS/FS/HS speed and also supports OTG functionality. > + The USB OTG controller communicates with this phy through stand UTMI > + interface. > + > +endif > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile > index 9e9560f..471c525 100644 > --- a/drivers/phy/Makefile > +++ b/drivers/phy/Makefile > @@ -3,3 +3,4 @@ > # > > obj-$(CONFIG_GENERIC_PHY)+= phy-core.o > +obj-$(CONFIG_PHY_AM_USB) += phy-am-usb.o > diff --git a/drivers/phy/phy-am-usb.c b/drivers/phy/phy-am-usb.c > new file mode 100644 > index 000..d0b0749 > --- /dev/null > +++ b/drivers/phy/phy-am-usb.c > @@ -0,0 +1,222 @@ > +/* > + * phy-am-usb.c - USB PHY, talking to usb controller in AMXXX. > + * > + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * Author: George Cherian > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +struct am_usb { > + struct usb_phy phy; > + struct device *dev; > + struct device *control_dev; > + struct clk *optclk; > + u32 id; > +}; > + > +#define phy_to_amphy(x) container_of((x), struct am_phy, phy) > + > + additional blank line.. > +static int am_usb_set_host(struct usb_otg *otg, struct usb_bus *host) > +{ > + struct usb_phy *phy = otg->phy; > + > + otg->host = host; > + if (!host) > + phy->state = OTG_STATE_UNDEFINED; > + > + return 0; > +} > + > +static int am_usb_set_peripheral(struct usb_otg *otg, > + struct usb_gadget *gadget) > +{ > + struct usb_phy *phy = otg->phy; > + > + otg->gadget = gadget; > + if (!gadget) > + phy->state = OTG_STATE_UNDEFINED; > + > + return 0; > +} > + > + > + ditto.. > +static int am_usb_power_off(struct phy *x) > +{ > + struct am_usb *phy = phy_get_drvdata(x); > + > + omap_control_am335x_phy_power(phy->control_dev, 0, phy->id); > + > + return 0; > +} > + > +static int am_usb_power_on(struct phy *x) > +{ > + struct am_usb *phy = phy_get_drvdata(x); > + > + omap_control_am335x_phy_power(phy->control_dev, 1, phy->id); > + > + return 0; > +} > + > +static struct phy_ops ops = { > + .power_on = am_usb_power_on, > + .power_off = am_usb_power_off, > + .owner = THIS_MODULE, > +}; > + > +static int am_usb2_probe(struct platform_device *pdev) > +{ > + struct device_node *np = pdev->dev.of_node; > + struct am_usb *phy; > + struct phy *generic_phy; > + struct usb_otg *otg; > + struct phy_provider *phy_provider; > + > + phy = devm_kzalloc(>dev, sizeof(*phy), GFP_KERNEL); You might have to bail out of memory allocation fails. > + > + otg = devm_kzalloc(>dev, sizeof(*otg), GFP_KERNEL); ditto. > + > + phy->dev= >dev; > + > + if (np) > + of_property_read_u32(np, "id", >id); > + > + phy->phy.dev= phy->dev; > + phy->phy.label = "am-usb2"; > + phy->phy.otg
Re: [PATCH v2 2/4] phy: phy-amxxxx-usb: Add PHY driver for amxxxx platform
Hi, On Friday 19 July 2013 06:04 PM, George Cherian wrote: Adds phy driver support for am33xx platform, the host/device peripheral controller shall get this phy object to control the phy operations. Signed-off-by: George Cherian george.cher...@ti.com --- drivers/phy/Kconfig | 12 +++ drivers/phy/Makefile | 1 + drivers/phy/phy-am-usb.c | 222 +++ 3 files changed, 235 insertions(+) create mode 100644 drivers/phy/phy-am-usb.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 5f85909..55087ab 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -11,3 +11,15 @@ menuconfig GENERIC_PHY devices present in the kernel. This layer will have the generic API by which phy drivers can create PHY using the phy framework and phy users can obtain reference to the PHY. +if GENERIC_PHY Greg has some comments about the generic PHY framework. So instead of having like this, you might have to select GENERIC_PHY in the Kconfig of your phy driver. + +config PHY_AM_USB + tristate AM USB2 PHY Driver + depends on SOC_AM33XX + help + Enable this to support the transceiver that is part of SOC. This + phy supports all LS/FS/HS speed and also supports OTG functionality. + The USB OTG controller communicates with this phy through stand UTMI + interface. + +endif diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 9e9560f..471c525 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_GENERIC_PHY)+= phy-core.o +obj-$(CONFIG_PHY_AM_USB) += phy-am-usb.o diff --git a/drivers/phy/phy-am-usb.c b/drivers/phy/phy-am-usb.c new file mode 100644 index 000..d0b0749 --- /dev/null +++ b/drivers/phy/phy-am-usb.c @@ -0,0 +1,222 @@ +/* + * phy-am-usb.c - USB PHY, talking to usb controller in AMXXX. + * + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Author: George Cherian george.cher...@ti.com + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include linux/module.h +#include linux/platform_device.h +#include linux/of.h +#include linux/usb/otg.h +#include linux/clk.h +#include linux/pm_runtime.h +#include linux/usb/omap_control_usb.h +#include linux/phy/phy.h + +struct am_usb { + struct usb_phy phy; + struct device *dev; + struct device *control_dev; + struct clk *optclk; + u32 id; +}; + +#define phy_to_amphy(x) container_of((x), struct am_phy, phy) + + additional blank line.. +static int am_usb_set_host(struct usb_otg *otg, struct usb_bus *host) +{ + struct usb_phy *phy = otg-phy; + + otg-host = host; + if (!host) + phy-state = OTG_STATE_UNDEFINED; + + return 0; +} + +static int am_usb_set_peripheral(struct usb_otg *otg, + struct usb_gadget *gadget) +{ + struct usb_phy *phy = otg-phy; + + otg-gadget = gadget; + if (!gadget) + phy-state = OTG_STATE_UNDEFINED; + + return 0; +} + + + ditto.. +static int am_usb_power_off(struct phy *x) +{ + struct am_usb *phy = phy_get_drvdata(x); + + omap_control_am335x_phy_power(phy-control_dev, 0, phy-id); + + return 0; +} + +static int am_usb_power_on(struct phy *x) +{ + struct am_usb *phy = phy_get_drvdata(x); + + omap_control_am335x_phy_power(phy-control_dev, 1, phy-id); + + return 0; +} + +static struct phy_ops ops = { + .power_on = am_usb_power_on, + .power_off = am_usb_power_off, + .owner = THIS_MODULE, +}; + +static int am_usb2_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev-dev.of_node; + struct am_usb *phy; + struct phy *generic_phy; + struct usb_otg *otg; + struct phy_provider *phy_provider; + + phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL); You might have to bail out of memory allocation fails. + + otg = devm_kzalloc(pdev-dev, sizeof(*otg), GFP_KERNEL); ditto. + + phy-dev= pdev-dev; + + if (np) + of_property_read_u32(np, id, phy-id); + + phy-phy.dev= phy-dev; + phy-phy.label = am-usb2; +