LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v5 1/3] usb: fsl-mxc-udc: replace cpu_is_xxx() with platform_device_id
From: Peter Chen @ 2013-01-17  9:28 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: r58472, gregkh, linux-usb, kernel, Shawn Guo, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <20130117091422.GF10814@arwen.pp.htv.fi>

On Thu, Jan 17, 2013 at 11:14:22AM +0200, Felipe Balbi wrote:
> On Wed, Jan 16, 2013 at 09:48:25AM +0800, Peter Chen wrote:
> > On Tue, Jan 15, 2013 at 10:03:46PM +0800, Shawn Guo wrote:
> > > On Tue, Jan 15, 2013 at 10:29:33AM +0800, Peter Chen wrote:
> > > > As mach/hardware.h is deleted, we need to use platform_device_id to
> > > > differentiate SoCs. Besides, one cpu_is_mx35 is useless as it has
> > > > already used pdata to differentiate runtime
> > > > 
> > > > Meanwhile we update the platform code accordingly.
> > > > 
> > > > Signed-off-by: Peter Chen <peter.chen@freescale.com>
> > > > ---
> > > >  arch/arm/mach-imx/devices/devices-common.h        |    1 +
> > > >  arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c |   15 ++++---
> > > >  drivers/usb/gadget/fsl_mxc_udc.c                  |   24 +++++-------
> > > >  drivers/usb/gadget/fsl_udc_core.c                 |   42 +++++++++++++--------
> > > >  4 files changed, 45 insertions(+), 37 deletions(-)
> > > 
> > > Since we are splitting the original patch anyway, it's a bit strange
> > > to me that you are mixing arch/arm/mach-imx and drivers/usb/gadget
> > > in this patch.  I'm fine with it, since I assume all the patches to
> > > go via USB tree anyway.
> > > 
> > > > 
> > > > diff --git a/arch/arm/mach-imx/devices/devices-common.h b/arch/arm/mach-imx/devices/devices-common.h
> > > > index 6277baf..9bd5777 100644
> > > > --- a/arch/arm/mach-imx/devices/devices-common.h
> > > > +++ b/arch/arm/mach-imx/devices/devices-common.h
> > > > @@ -63,6 +63,7 @@ struct platform_device *__init imx_add_flexcan(
> > > >  
> > > >  #include <linux/fsl_devices.h>
> > > >  struct imx_fsl_usb2_udc_data {
> > > > +	const char *devid;
> > > >  	resource_size_t iobase;
> > > >  	resource_size_t irq;
> > > >  };
> > > > diff --git a/arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c b/arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c
> > > > index 37e4439..fb527c7 100644
> > > > --- a/arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c
> > > > +++ b/arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c
> > > > @@ -11,35 +11,36 @@
> > > >  #include "../hardware.h"
> > > >  #include "devices-common.h"
> > > >  
> > > > -#define imx_fsl_usb2_udc_data_entry_single(soc)				\
> > > > +#define imx_fsl_usb2_udc_data_entry_single(soc, _devid)			\
> > > >  	{								\
> > > > +		.devid = _devid,					\
> > > >  		.iobase = soc ## _USB_OTG_BASE_ADDR,			\
> > > >  		.irq = soc ## _INT_USB_OTG,				\
> > > >  	}
> > > >  
> > > >  #ifdef CONFIG_SOC_IMX25
> > > >  const struct imx_fsl_usb2_udc_data imx25_fsl_usb2_udc_data __initconst =
> > > > -	imx_fsl_usb2_udc_data_entry_single(MX25);
> > > > +	imx_fsl_usb2_udc_data_entry_single(MX25, "imx-udc-mx25");
> > > >  #endif /* ifdef CONFIG_SOC_IMX25 */
> > > >  
> > > >  #ifdef CONFIG_SOC_IMX27
> > > >  const struct imx_fsl_usb2_udc_data imx27_fsl_usb2_udc_data __initconst =
> > > > -	imx_fsl_usb2_udc_data_entry_single(MX27);
> > > > +	imx_fsl_usb2_udc_data_entry_single(MX27, "imx-udc-mx27");
> > > >  #endif /* ifdef CONFIG_SOC_IMX27 */
> > > >  
> > > >  #ifdef CONFIG_SOC_IMX31
> > > >  const struct imx_fsl_usb2_udc_data imx31_fsl_usb2_udc_data __initconst =
> > > > -	imx_fsl_usb2_udc_data_entry_single(MX31);
> > > > +	imx_fsl_usb2_udc_data_entry_single(MX31, "imx-udc-mx31");
> > > >  #endif /* ifdef CONFIG_SOC_IMX31 */
> > > >  
> > > >  #ifdef CONFIG_SOC_IMX35
> > > >  const struct imx_fsl_usb2_udc_data imx35_fsl_usb2_udc_data __initconst =
> > > > -	imx_fsl_usb2_udc_data_entry_single(MX35);
> > > > +	imx_fsl_usb2_udc_data_entry_single(MX35, "imx-udc-mx35");
> > > >  #endif /* ifdef CONFIG_SOC_IMX35 */
> > > >  
> > > >  #ifdef CONFIG_SOC_IMX51
> > > >  const struct imx_fsl_usb2_udc_data imx51_fsl_usb2_udc_data __initconst =
> > > > -	imx_fsl_usb2_udc_data_entry_single(MX51);
> > > > +	imx_fsl_usb2_udc_data_entry_single(MX51, "imx-udc-mx51");
> > > >  #endif
> > > >  
> > > >  struct platform_device *__init imx_add_fsl_usb2_udc(
> > > > @@ -57,7 +58,7 @@ struct platform_device *__init imx_add_fsl_usb2_udc(
> > > >  			.flags = IORESOURCE_IRQ,
> > > >  		},
> > > >  	};
> > > > -	return imx_add_platform_device_dmamask("fsl-usb2-udc", -1,
> > > > +	return imx_add_platform_device_dmamask(data->devid, -1,
> > > >  			res, ARRAY_SIZE(res),
> > > >  			pdata, sizeof(*pdata), DMA_BIT_MASK(32));
> > > >  }
> > > 
> > > <snip>
> > > 
> > > > +static const struct platform_device_id fsl_udc_devtype[] = {
> > > > +	{
> > > > +		.name = "imx-udc-mx25",
> > > > +	}, {
> > > > +		.name = "imx-udc-mx27",
> > > > +	}, {
> > > > +		.name = "imx-udc-mx31",
> > > > +	}, {
> > > > +		.name = "imx-udc-mx35",
> > > > +	}, {
> > > > +		.name = "imx-udc-mx51",
> > > > +	}
> > > > +};
> > > 
> > > From what I understand balbi's comment, he dislikes this full list of
> > > device id.  Instead, he prefers to something like below.
> > > 
> > > static const struct platform_device_id fsl_udc_devtype[] = {
> > > 	{
> > > 		.name = "imx-udc-mx27",
> > > 	}, {
> > > 		.name = "imx-udc-mx51",
> > > 	}
> > > };
> > > 
> > > It basically tells that we are handling two type of devices here, one
> > > is imx-udc-mx27 type and the other is imx-udc-mx51 type, with mx25/31/35
> > > completely compatible with mx27 type.  We choose mx27 instead of mx25
> > > to define the type because mx27 Si came out earlier than mx25.  That
> > > said, we generally choose the earlies SoC name to define a particular
> > > version of IP block, since hardware version is mostly unavailable or
> > > unreliable.
> > > 
> > > But that also means in platform code which create the platform_device,
> > > you will need to use name "imx-udc-mx27" for even mx25/31/35.
> > > 
> > > 	imx_fsl_usb2_udc_data_entry_single(MX25, "imx-udc-mx27");
> > > 	imx_fsl_usb2_udc_data_entry_single(MX31, "imx-udc-mx27");
> > > 	imx_fsl_usb2_udc_data_entry_single(MX35, "imx-udc-mx27");
> > > 
> > > Considering this is a piece of code we will not use for any new
> > > hardware, I'm fine with either way.
> > > 
> > > So, balbi, it's all your call to accept the series as it is or ask for
> > > another iteration.
> 
> right :-)
> 
> > Thanks Shawn. Let's see Felipe's comment, nevertheless, I will send v6 patch
> > due to a compile error at mx25
> 
> Shawn is right.

In fact, this driver is just the temp solution, we will use chipidea
in future, so just take all i.mx usb as two kinds of ip are ok.

Do you want me to change like Shawn said, or current version is ok?

> 
> -- 
> balbi



-- 

Best Regards,
Peter Chen

^ permalink raw reply

* Re: [PATCH v5 1/3] usb: fsl-mxc-udc: replace cpu_is_xxx() with platform_device_id
From: Felipe Balbi @ 2013-01-17  9:14 UTC (permalink / raw)
  To: Peter Chen
  Cc: r58472, gregkh, linux-usb, balbi, kernel, Shawn Guo, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <20130116014824.GD16514@nchen-desktop>

[-- Attachment #1: Type: text/plain, Size: 6058 bytes --]

On Wed, Jan 16, 2013 at 09:48:25AM +0800, Peter Chen wrote:
> On Tue, Jan 15, 2013 at 10:03:46PM +0800, Shawn Guo wrote:
> > On Tue, Jan 15, 2013 at 10:29:33AM +0800, Peter Chen wrote:
> > > As mach/hardware.h is deleted, we need to use platform_device_id to
> > > differentiate SoCs. Besides, one cpu_is_mx35 is useless as it has
> > > already used pdata to differentiate runtime
> > > 
> > > Meanwhile we update the platform code accordingly.
> > > 
> > > Signed-off-by: Peter Chen <peter.chen@freescale.com>
> > > ---
> > >  arch/arm/mach-imx/devices/devices-common.h        |    1 +
> > >  arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c |   15 ++++---
> > >  drivers/usb/gadget/fsl_mxc_udc.c                  |   24 +++++-------
> > >  drivers/usb/gadget/fsl_udc_core.c                 |   42 +++++++++++++--------
> > >  4 files changed, 45 insertions(+), 37 deletions(-)
> > 
> > Since we are splitting the original patch anyway, it's a bit strange
> > to me that you are mixing arch/arm/mach-imx and drivers/usb/gadget
> > in this patch.  I'm fine with it, since I assume all the patches to
> > go via USB tree anyway.
> > 
> > > 
> > > diff --git a/arch/arm/mach-imx/devices/devices-common.h b/arch/arm/mach-imx/devices/devices-common.h
> > > index 6277baf..9bd5777 100644
> > > --- a/arch/arm/mach-imx/devices/devices-common.h
> > > +++ b/arch/arm/mach-imx/devices/devices-common.h
> > > @@ -63,6 +63,7 @@ struct platform_device *__init imx_add_flexcan(
> > >  
> > >  #include <linux/fsl_devices.h>
> > >  struct imx_fsl_usb2_udc_data {
> > > +	const char *devid;
> > >  	resource_size_t iobase;
> > >  	resource_size_t irq;
> > >  };
> > > diff --git a/arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c b/arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c
> > > index 37e4439..fb527c7 100644
> > > --- a/arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c
> > > +++ b/arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c
> > > @@ -11,35 +11,36 @@
> > >  #include "../hardware.h"
> > >  #include "devices-common.h"
> > >  
> > > -#define imx_fsl_usb2_udc_data_entry_single(soc)				\
> > > +#define imx_fsl_usb2_udc_data_entry_single(soc, _devid)			\
> > >  	{								\
> > > +		.devid = _devid,					\
> > >  		.iobase = soc ## _USB_OTG_BASE_ADDR,			\
> > >  		.irq = soc ## _INT_USB_OTG,				\
> > >  	}
> > >  
> > >  #ifdef CONFIG_SOC_IMX25
> > >  const struct imx_fsl_usb2_udc_data imx25_fsl_usb2_udc_data __initconst =
> > > -	imx_fsl_usb2_udc_data_entry_single(MX25);
> > > +	imx_fsl_usb2_udc_data_entry_single(MX25, "imx-udc-mx25");
> > >  #endif /* ifdef CONFIG_SOC_IMX25 */
> > >  
> > >  #ifdef CONFIG_SOC_IMX27
> > >  const struct imx_fsl_usb2_udc_data imx27_fsl_usb2_udc_data __initconst =
> > > -	imx_fsl_usb2_udc_data_entry_single(MX27);
> > > +	imx_fsl_usb2_udc_data_entry_single(MX27, "imx-udc-mx27");
> > >  #endif /* ifdef CONFIG_SOC_IMX27 */
> > >  
> > >  #ifdef CONFIG_SOC_IMX31
> > >  const struct imx_fsl_usb2_udc_data imx31_fsl_usb2_udc_data __initconst =
> > > -	imx_fsl_usb2_udc_data_entry_single(MX31);
> > > +	imx_fsl_usb2_udc_data_entry_single(MX31, "imx-udc-mx31");
> > >  #endif /* ifdef CONFIG_SOC_IMX31 */
> > >  
> > >  #ifdef CONFIG_SOC_IMX35
> > >  const struct imx_fsl_usb2_udc_data imx35_fsl_usb2_udc_data __initconst =
> > > -	imx_fsl_usb2_udc_data_entry_single(MX35);
> > > +	imx_fsl_usb2_udc_data_entry_single(MX35, "imx-udc-mx35");
> > >  #endif /* ifdef CONFIG_SOC_IMX35 */
> > >  
> > >  #ifdef CONFIG_SOC_IMX51
> > >  const struct imx_fsl_usb2_udc_data imx51_fsl_usb2_udc_data __initconst =
> > > -	imx_fsl_usb2_udc_data_entry_single(MX51);
> > > +	imx_fsl_usb2_udc_data_entry_single(MX51, "imx-udc-mx51");
> > >  #endif
> > >  
> > >  struct platform_device *__init imx_add_fsl_usb2_udc(
> > > @@ -57,7 +58,7 @@ struct platform_device *__init imx_add_fsl_usb2_udc(
> > >  			.flags = IORESOURCE_IRQ,
> > >  		},
> > >  	};
> > > -	return imx_add_platform_device_dmamask("fsl-usb2-udc", -1,
> > > +	return imx_add_platform_device_dmamask(data->devid, -1,
> > >  			res, ARRAY_SIZE(res),
> > >  			pdata, sizeof(*pdata), DMA_BIT_MASK(32));
> > >  }
> > 
> > <snip>
> > 
> > > +static const struct platform_device_id fsl_udc_devtype[] = {
> > > +	{
> > > +		.name = "imx-udc-mx25",
> > > +	}, {
> > > +		.name = "imx-udc-mx27",
> > > +	}, {
> > > +		.name = "imx-udc-mx31",
> > > +	}, {
> > > +		.name = "imx-udc-mx35",
> > > +	}, {
> > > +		.name = "imx-udc-mx51",
> > > +	}
> > > +};
> > 
> > From what I understand balbi's comment, he dislikes this full list of
> > device id.  Instead, he prefers to something like below.
> > 
> > static const struct platform_device_id fsl_udc_devtype[] = {
> > 	{
> > 		.name = "imx-udc-mx27",
> > 	}, {
> > 		.name = "imx-udc-mx51",
> > 	}
> > };
> > 
> > It basically tells that we are handling two type of devices here, one
> > is imx-udc-mx27 type and the other is imx-udc-mx51 type, with mx25/31/35
> > completely compatible with mx27 type.  We choose mx27 instead of mx25
> > to define the type because mx27 Si came out earlier than mx25.  That
> > said, we generally choose the earlies SoC name to define a particular
> > version of IP block, since hardware version is mostly unavailable or
> > unreliable.
> > 
> > But that also means in platform code which create the platform_device,
> > you will need to use name "imx-udc-mx27" for even mx25/31/35.
> > 
> > 	imx_fsl_usb2_udc_data_entry_single(MX25, "imx-udc-mx27");
> > 	imx_fsl_usb2_udc_data_entry_single(MX31, "imx-udc-mx27");
> > 	imx_fsl_usb2_udc_data_entry_single(MX35, "imx-udc-mx27");
> > 
> > Considering this is a piece of code we will not use for any new
> > hardware, I'm fine with either way.
> > 
> > So, balbi, it's all your call to accept the series as it is or ask for
> > another iteration.

right :-)

> Thanks Shawn. Let's see Felipe's comment, nevertheless, I will send v6 patch
> due to a compile error at mx25

Shawn is right.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [RFC PATCH 3/6] usb: otg: utils: change the phy lib to support multiple PHYs of same type
From: Simon Horman @ 2013-01-17  0:31 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: linux-doc, tony, linux, linux-sh, alexander.shishkin, stern,
	devicetree-discuss, linuxppc-dev, rob.herring, haojian.zhuang,
	linux-omap, linux-arm-kernel, eric.y.miao, b-cousson, gregkh,
	linux-usb, linux-kernel, balbi, cbou, rob, dwmw2
In-Reply-To: <1358348462-27693-4-git-send-email-kishon@ti.com>

On Wed, Jan 16, 2013 at 08:30:59PM +0530, Kishon Vijay Abraham I wrote:
> In order to add support for multipe PHY's of the same type, the API's
> for adding PHY and getting PHY has been changed. Now the binding
> information of the PHY and controller should be done in platform file
> using usb_bind_phy API. And for getting a PHY, the device pointer of the
> USB controller and an index should be passed. Based on the binding
> information that is added in the platform file, get_phy will return the
> approappropriate PHY.
> 
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  arch/arm/mach-shmobile/board-marzen.c |    2 +-

Modification to the above file:

Acked-by: Simon Horman <horms+renesas@verge.net.au>

^ permalink raw reply

* Re: [RFC PATCH v2 00/12] System device hot-plug framework
From: Rafael J. Wysocki @ 2013-01-17  0:50 UTC (permalink / raw)
  To: Toshi Kani
  Cc: linux-s390, jiang.liu, wency, linux-acpi, gregkh, linux-kernel,
	linux-mm, isimatu.yasuaki, yinghai, srivatsa.bhat, guohanjun,
	bhelgaas, akpm, linuxppc-dev, lenb
In-Reply-To: <1357861230-29549-1-git-send-email-toshi.kani@hp.com>

On Thursday, January 10, 2013 04:40:18 PM Toshi Kani wrote:
> This patchset is a prototype of proposed system device hot-plug framework
> for design review.  Unlike other hot-plug environments, such as USB and
> PCI, there is no common framework for system device hot-plug [1].
> Therefore, this patchset is designed to provide a common framework for
> hot-plugging and online/offline operations of system devices, such as CPU,
> Memory and Node.  While this patchset only supports ACPI-based hot-plug
> operations, the framework itself is designed to be platform-neural and
> can support other FW architectures as necessary.
> 
> This patchset is based on Linus's tree (3.8-rc3).
> 
> I have seen a few stability issues with 3.8-rc3 in my testing and will
> look into their solutions.
> 
> [1] System device hot-plug frameworks for ppc and s390 are implemented
>     for specific platforms and products.
> 
> 
> Background: System Device Initialization
> ========================================
> System devices, such as CPU and memory, must be initialized during early
> boot sequence as they are the essential components to provide low-level
> services, ex. scheduling, memory allocation and interrupts, which are
> the foundations of the kernel services.  start_kernel() and kernel_init()
> manage the boot-up sequence to initialize system devices and low-level
> services in pre-defined order as shown below. 
> 
>   start_kernel()
>     boot_cpu_init()          // init cpu0
>     setup_arch()
>       efi_init()             // init EFI memory map
>       initmem_init()         // init NUMA
>       x86_init.paging.pagetable_init() // init page table
>       acpi_boot_init()       // parse ACPI MADT table
>         :
>   kernel_init()
>     kernel_init_freeable()
>       smp_init()             // init other CPUs
>         :
>       do_basic_setup()
>         driver_init()
>           cpu_dev_init()     // build system/cpu tree
>           memory_dev_init()  // build system/memory tree
>         do_initcalls()
>           acpi_init()        // build ACPI device tree
> 
> Note that drivers are initialized at the end of the boot sequence as they
> depend on the kernel services from system devices.  Hence, while system
> devices may be exposed to sysfs with their pseudo drivers, their
> initialization may not be fully integrated into the driver structures.  
> 
> Overview of the System Device Hot-plug Framework
> ================================================
> Similar to the boot-up sequence, the system device hot-plug framework
> provides a sequencer that calls all registered handlers in pre-defined
> order for hot-add and hot-delete of system devices.  It allows any modules
> initializing system devices in the boot-up sequence to participate in
> the hot-plug operations as well.  In high-level, there are two types of
> handlers, 1) FW-dependent (ex. ACPI) handlers that enumerate or eject
> system devices, and 2) system device (ex. CPU, Memory) management handlers
> that online or offline the enumerated system devices.  Online/offline
> operations are sub-set of hot-add/delete operations.  The ordering of the
> handlers are symmetric between hot-add (online) and hot-delete (offline)
> operations.
> 
>         hot-add    online
>            |    ^    :    ^
>   HW Enum/ |    |    :    :
>     Eject  |    |    :    :
>            |    |    :    :
>   Online/  |    |    |    |
>   Offline  |    |    |    |
>            V    |    V    |
>              hot-del   offline
> 
> The handlers may not call other handlers directly to exceed their role.
> Therefore, the role of the handlers in their modules remains consistent
> with their role at the boot-up sequence.  For instance, the ACPI module
> may not perform online or offline of system devices.
> 
> System Device Hot-plug Operation
> ================================
> 
> Serialized Startup
> ------------------
> The framework provides an interface (hp_submit_req) to request a hot-plug
> operation.  All requests are queued to and run on a single work queue.
> The framework assures that there is only a single hot-plug or online/
> offline operation running at a time.  A single request may however target
> to multiple devices.  This makes the execution context of handlers to be
> consistent with the boot-up sequence and enables code sharing.
> 
> Phased Execution
> ----------------
> The framework proceeds hot-plug and online/offline operations in the 
> following three phases.  The modules can register their handlers to each
> phase.  The framework also initiates a roll-back operation if any hander
> failed in the validate or execute phase.
> 
> 1) Validate Phase - Handlers validate if they support a given request
> without making any changes to target device(s).  They check any known
> restrictions and/or prerequisite conditions to their modules, and fail
> an unsupported request before making any changes.  For instance, the
> memory module may check if a hot-remove request is targeted to movable
> ranges.
> 
> 2) Execute Phase - Handlers make requested change within the scope that
> its roll-back is possible in case of a failure.  Execute handlers must
> implement their roll-back procedures.
> 
> 3) Commit Phase - Handlers make the final change that cannot be rolled-back.
> For instance, the ACPI module invokes _EJ0 for a hot-remove operation.
> 
> System Device Management Modules
> ================================
> 
> CPU Handlers
> ------------
> CPU handlers are provided by the CPU driver in drivers/base/cpu.c, and
> perform CPU online/offline procedures when CPU device(s) is added or
> deleted during an operation.
> 
> Memory Handlers
> ---------------
> Memory handlers are provided by the memory module in mm/memory_hotplug.c,
> and perform Memory online/offline procedure when memory device(s) is
> added or deleted during an operation.
> 
> FW-dependent Modules
> ====================
> 
> ACPI Bus Handlers
> -----------------
> ACPI bus handlers are provided by the ACPI core in drivers/acpi/bus.c,
> and construct/destruct acpi_device object(s) during a hot-plug operation.
> 
> ACPI Resource Handlers
> ----------------------
> ACPI resource handlers are provided by the ACPI core in
> drivers/acpi/hp_resource.c, and set device resource information to
> a request during a hot-plug operation.  This device resource information
> is then consumed by the system device management modules for their
> online/offline procedure.
> 
> ACPI Drivers
> ------------
> ACPI drivers are called from the ACPI core during a hot-plug operation
> through the following interfaces.  ACPI drivers are not called from the
> framework directly, and remain internal to the ACPI core.  ACPI drivers
> may not initiate online/offline of a device.
> 
> .add - Construct device-specific information to a given acpi_device.
> Called at boot, hot-add and sysfs bind.
> 
> .remove - Destruct device-specific information to a given acpi_device.
> Called at hot-remove and sysfs unbind.
> 
> .resource - Set device-specific resource information to a given hot-plug
> request.  Called at hot-add and hot-remove.

At this point I'd like to clearly understand how the code is supposed to work.

>From what I can say at the moment it all boils down to having two (ordered)
lists of notifiers (shp_add_list, shp_del_list) that can be added to or removed
from with shp_register_handler() and shp_unregister_handler(), respectively
(BTW, the abbreviation "hdr" makes me think about a "header" rather than a
"handler", but maybe that's just me :-)), and a workqueue for requests (why do
we need a separate workqueue for that?).

Whoever needs to carry out a hotplug operation is supposed to prepare a request
and then put it into the workqueue with shp_submit_request().  The framework
will then execute all of the notifier callbacks from the appropriate notifier
list (depending on whether the operation is a hot-add or a hot-remove).  If any
of those callbacks returns an error code and it is not too late (the order of
the failing notifier is not too high), the already executed notifier callbacks
will be run again with the "rollback" argument set to 1 (why not to use bool?)
to indicate that they are supposed to bring things back to the initial state.
Error codes returned in that stage only cause messages to be printed.

Is the description above correct?

If so, it looks like subsystems are supposed to register notifiers (handlers)
for hotplug/hot-remove operations of the devices they handle.  They are
supposed to use predefined order values to indicate what kinds of devices
those are.  Then, hopefully, if they do everything correctly, and the
initiator of a hotplug/hot-remove operation prepares the request correctly,
the callbacks will be executed in the right order, they will find their
devices in the list attached to the request object and they will do what's
necessary with them.

Am I still on the right track?

If that's the case, I have a few questions.

(1) Why is this limited to system devices?

(2) What's the guarantee that the ordering of hot-removal (for example) of CPU
    cores with respect to memory and host bridges will always be the same?
    What if the CPU cores themselves need to be hot-removed in a specific
    order?

(3) What's the guarantee that the ordering of shp_add_list and shp_del_list
    will be in agreement with the ordering of the device hierarchy?

(4) Why do you think that the ordering of hot-plug operations needs to be
    independent of the device herarchy ordering?

(5) Why do you think it's a good idea to require every callback routine to
    browse the entire list of devices attached to the request object?  Wouldn't
    it be more convenient if they were called only for the types of devices
    they have declared to handle?  [That would reduce some code duplication,
    for example.]

(6) Why is it convenient to use order values (priorities) of notifiers to
    indicate both the ordering with respect to the other notifiers and the
    "level" (e.g. whether or not rollback is possible) at the same time?  Those
    things appear to be conceptually distinct.

(7) Why callbacks used for "add" operations still need to check if the
    operation type is "add" (cpu_add_execute() does that for example)?

(8) What problems *exactly* this is supposed to address?  Can you give a few
    examples, please?

I guess I'll have more questions going forward.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply

* Re: [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
From: Sukadev Bhattiprolu @ 2013-01-16 18:58 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Andi Kleen, Peter Zijlstra, robert.richter, Greg KH,
	Anton Blanchard, linux-kernel, Stephane Eranian, linuxppc-dev,
	Ingo Molnar, Paul Mackerras, Arnaldo Carvalho de Melo
In-Reply-To: <20130116113013.GA1042@krava.brq.redhat.com>

Jiri Olsa [jolsa@redhat.com] wrote:
| On Tue, Jan 15, 2013 at 03:57:59PM -0300, Arnaldo Carvalho de Melo wrote:
| > Em Wed, Jan 09, 2013 at 05:07:03PM -0800, Sukadev Bhattiprolu escreveu:
| > > [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
| > > 
| > > This patchset addes two new sets of files to sysfs:
| > > 
| > > 	- generic and POWER-specific perf events in /sys/devices/cpu/events/
| > > 	- perf event config format in /sys/devices/cpu/format/event
| > > 
| > > Document the format of these files which would become part of the ABI.
| > > 
| > > Changelog[v3]:
| > > 	[Greg KH] Include ABI documentation.
| > 
| > Jiri, can I have your ack on this one too?
| 
| hm, we already already 'format' definition but in testing section
| (and we are missing 'events' definition there.. my bad)

I see that file now ! I have removed that documentation from my patch.
| 
| anyway, after reading Documentation/ABI/README looks like we
| should go for 'testing' section with this as well.. stable
| seems scary at this point ;-)

Agree.

Here is the updated patch.
---

This patchset addes two new sets of files to sysfs for POWER architecture.

	- perf event config format in /sys/devices/cpu/format/event
	- generic and POWER-specific perf events in /sys/devices/cpu/events/

The format of the first file is already documented in:

	Documentation/ABI/testing/sysfs-bus-event_source-devices-format

Document the format of the second set of files '/sys/devices/cpu/events/*'
which would also become part of the ABI.

Changelog[v3.1]:
	(small changes to this one patch).
	[Jiri Olsa]: Remove the documentation for the 'config format' file
	as it is already documented.
	[Jiri Olsa]: Move the documentation of 'events' also to 'testing/'

Changelog[v3]:
	[Greg KH] Include ABI documentation.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 .../testing/sysfs-bus-event_source-devices-events  |   58 ++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)
 delete mode 100644 Documentation/ABI/stable/sysfs-devices-cpu-events
 create mode 100644 Documentation/ABI/testing/sysfs-bus-event_source-devices-events

diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-events b/Documentation/ABI/stable/sysfs-devices-cpu-events
deleted file mode 100644
index e69de29..0000000
diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-events b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
new file mode 100644
index 0000000..2c4081e
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-events
@@ -0,0 +1,58 @@
+What:		/sys/devices/cpu/events/
+		/sys/devices/cpu/events/branch-misses
+		/sys/devices/cpu/events/cache-references
+		/sys/devices/cpu/events/cache-misses
+		/sys/devices/cpu/events/stalled-cycles-frontend
+		/sys/devices/cpu/events/branch-instructions
+		/sys/devices/cpu/events/stalled-cycles-backend
+		/sys/devices/cpu/events/instructions
+		/sys/devices/cpu/events/cpu-cycles
+
+Date:		2012/01/NN
+
+Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
+
+Description:	Generic performance monitoring events
+
+		A collection of performance monitoring events that may be
+		supported by many/most CPUs. These events can be monitored
+		using the 'perf(1)' tool.
+
+		The contents of each file would look like:
+
+			event=0xNNNN
+
+		where 'N' is a hex digit and the number '0xNNNN' shows the
+		"raw code" for the perf event identified by the file's
+		"basename".
+
+
+What: 		/sys/devices/cpu/events/PM_LD_MISS_L1
+		/sys/devices/cpu/events/PM_LD_REF_L1
+		/sys/devices/cpu/events/PM_CYC
+		/sys/devices/cpu/events/PM_BRU_FIN
+		/sys/devices/cpu/events/PM_GCT_NOSLOT_CYC
+		/sys/devices/cpu/events/PM_BRU_MPRED
+		/sys/devices/cpu/events/PM_INST_CMPL
+		/sys/devices/cpu/events/PM_CMPLU_STALL
+
+Date:		2013/01/08
+
+Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
+		Linux Powerpc mailing list <linuxppc-dev@ozlabs.org>
+
+Description:	POWER-systems specific performance monitoring events
+
+		A collection of performance monitoring events that may be
+		supported by the POWER CPU. These events can be monitored
+		using the 'perf(1)' tool.
+
+		These events may not be supported by other CPUs.
+
+		The contents of each file would look like:
+
+			event=0xNNNN
+
+		where 'N' is a hex digit and the number '0xNNNN' shows the
+		"raw code" for the perf event identified by the file's
+		"basename".
-- 
1.7.1

^ permalink raw reply related

* Re: [PATCH] KVM: PPC: add paravirt idle loop for 64-bit book E
From: Scott Wood @ 2013-01-16 17:44 UTC (permalink / raw)
  To: Stuart Yoder; +Cc: kvm-ppc, linuxppc-dev, agraf, kvm, Stuart Yoder
In-Reply-To: <1358356884-14216-1-git-send-email-stuart.yoder@freescale.com>

On 01/16/2013 11:21:24 AM, Stuart Yoder wrote:
> From: Stuart Yoder <stuart.yoder@freescale.com>
>=20
> loop was derived from book3e_idle()
>=20
> Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
> ---
>  arch/powerpc/kernel/epapr_hcalls.S |   63 =20
> ++++++++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
>=20
> diff --git a/arch/powerpc/kernel/epapr_hcalls.S =20
> b/arch/powerpc/kernel/epapr_hcalls.S
> index 62c0dc2..6a46bfb 100644
> --- a/arch/powerpc/kernel/epapr_hcalls.S
> +++ b/arch/powerpc/kernel/epapr_hcalls.S
> @@ -17,6 +17,68 @@
>  #include <asm/asm-compat.h>
>  #include <asm/asm-offsets.h>
>=20
> +#ifdef CONFIG_PPC64
> +/* epapr_ev_idle() was derived from book3e_idle() */
> +_GLOBAL(epapr_ev_idle)
> +	/* Save LR for later */
> +	mflr	r0
> +	std	r0,16(r1)
> +
> +	/* Hard disable interrupts */
> +	wrteei	0
> +
> +	/* Now check if an interrupt came in while we were soft disabled
> +	 * since we may otherwise lose it (doorbells etc...).
> +	 */
> +	lbz	r3,PACAIRQHAPPENED(r13)
> +	cmpwi	cr0,r3,0
> +	bnelr
> +
> +	/* Now we are going to mark ourselves as soft and hard enabled =20
> in
> +	 * order to be able to take interrupts while asleep. We inform =20
> lockdep
> +	 * of that. We don't actually turn interrupts on just yet tho.
> +	 */
> +#ifdef CONFIG_TRACE_IRQFLAGS
> +	stdu    r1,-128(r1)
> +	bl	.trace_hardirqs_on
> +	addi    r1,r1,128
> +#endif
> +	li	r0,1
> +	stb	r0,PACASOFTIRQEN(r13)
> +=09
> +	/* Interrupts will make use return to LR, so get something we =20
> want
> +	 * in there
> +	 */
> +	bl	1f
> +
> +	/* And return (interrupts are on) */
> +	ld	r0,16(r1)
> +	mtlr	r0
> +	blr
> +
> +1:	/* Let's set the _TLF_NAPPING flag so interrupts make us return
> +	 * to the right spot
> +	*/
> +	CURRENT_THREAD_INFO(r11, r1)
> +	ld	r10,TI_LOCAL_FLAGS(r11)
> +	ori	r10,r10,_TLF_NAPPING
> +	std	r10,TI_LOCAL_FLAGS(r11)
> +
> +	/* We can now re-enable hard interrupts and go to sleep */
> +	wrteei	1
> +idle_loop:
> +	LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
> +
> +.global epapr_ev_idle_start
> +epapr_ev_idle_start:
> +	li	r3, -1
> +	nop
> +	nop
> +	nop
> +	b	idle_loop
> +

We should probably do this as an assembler macro, so we can have one =20
instance of it that gets instantiated for both "wait" and "ev_idle".

-Scott=

^ permalink raw reply

* [PATCH] KVM: PPC: add paravirt idle loop for 64-bit book E
From: Stuart Yoder @ 2013-01-16 17:21 UTC (permalink / raw)
  To: agraf; +Cc: linuxppc-dev, kvm-ppc, kvm, Stuart Yoder

From: Stuart Yoder <stuart.yoder@freescale.com>

loop was derived from book3e_idle()

Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
---
 arch/powerpc/kernel/epapr_hcalls.S |   63 ++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/arch/powerpc/kernel/epapr_hcalls.S b/arch/powerpc/kernel/epapr_hcalls.S
index 62c0dc2..6a46bfb 100644
--- a/arch/powerpc/kernel/epapr_hcalls.S
+++ b/arch/powerpc/kernel/epapr_hcalls.S
@@ -17,6 +17,68 @@
 #include <asm/asm-compat.h>
 #include <asm/asm-offsets.h>
 
+#ifdef CONFIG_PPC64
+/* epapr_ev_idle() was derived from book3e_idle() */
+_GLOBAL(epapr_ev_idle)
+	/* Save LR for later */
+	mflr	r0
+	std	r0,16(r1)
+
+	/* Hard disable interrupts */
+	wrteei	0
+
+	/* Now check if an interrupt came in while we were soft disabled
+	 * since we may otherwise lose it (doorbells etc...).
+	 */
+	lbz	r3,PACAIRQHAPPENED(r13)
+	cmpwi	cr0,r3,0
+	bnelr
+
+	/* Now we are going to mark ourselves as soft and hard enabled in
+	 * order to be able to take interrupts while asleep. We inform lockdep
+	 * of that. We don't actually turn interrupts on just yet tho.
+	 */
+#ifdef CONFIG_TRACE_IRQFLAGS
+	stdu    r1,-128(r1)
+	bl	.trace_hardirqs_on
+	addi    r1,r1,128
+#endif
+	li	r0,1
+	stb	r0,PACASOFTIRQEN(r13)
+	
+	/* Interrupts will make use return to LR, so get something we want
+	 * in there
+	 */
+	bl	1f
+
+	/* And return (interrupts are on) */
+	ld	r0,16(r1)
+	mtlr	r0
+	blr
+
+1:	/* Let's set the _TLF_NAPPING flag so interrupts make us return
+	 * to the right spot
+	*/
+	CURRENT_THREAD_INFO(r11, r1)
+	ld	r10,TI_LOCAL_FLAGS(r11)
+	ori	r10,r10,_TLF_NAPPING
+	std	r10,TI_LOCAL_FLAGS(r11)
+
+	/* We can now re-enable hard interrupts and go to sleep */
+	wrteei	1
+idle_loop:
+	LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
+
+.global epapr_ev_idle_start
+epapr_ev_idle_start:
+	li	r3, -1
+	nop
+	nop
+	nop
+	b	idle_loop
+
+#else /* CONFIG_PPC64 */
+
 /* epapr_ev_idle() was derived from e500_idle() */
 _GLOBAL(epapr_ev_idle)
 	CURRENT_THREAD_INFO(r3, r1)
@@ -42,6 +104,7 @@ epapr_ev_idle_start:
 	 * _TLF_NAPPING.
 	 */
 	b	idle_loop
+#endif
 
 /* Hypercall entry point. Will be patched with device tree instructions. */
 .global epapr_hypercall_start
-- 
1.7.9.7

^ permalink raw reply related

* [RFC PATCH 6/6] USB: MUSB: OMAP: get PHY by phandle for dt boot
From: Kishon Vijay Abraham I @ 2013-01-16 15:01 UTC (permalink / raw)
  To: devicetree-discuss, linux-doc, linux-kernel, linux-omap,
	linux-arm-kernel, linux-usb, linux-sh, linuxppc-dev, balbi
  Cc: linux, b-cousson, tony, gregkh, rob.herring, kishon, cbou,
	alexander.shishkin, horms, stern, haojian.zhuang, rob,
	eric.y.miao, dwmw2
In-Reply-To: <1358348462-27693-1-git-send-email-kishon@ti.com>

The OMAP glue has been modified to get PHY by phandle for dt boot.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/musb/omap2430.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 3628a50..08709cf 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -346,7 +346,12 @@ static int omap2430_musb_init(struct musb *musb)
 	 * up through ULPI.  TWL4030-family PMICs include one,
 	 * which needs a driver, drivers aren't always needed.
 	 */
-	musb->xceiv = devm_usb_get_phy(dev, 0);
+	if (dev->parent->of_node)
+		musb->xceiv = devm_usb_get_phy_by_phandle(dev->parent,
+		    "usb_phy", 0);
+	else
+		musb->xceiv = devm_usb_get_phy(dev, 0);
+
 	if (IS_ERR_OR_NULL(musb->xceiv)) {
 		pr_err("HS USB OTG: no transceiver configured\n");
 		return -ENODEV;
-- 
1.7.9.5

^ permalink raw reply related

* [RFC PATCH 5/6] usb: otg: add device tree support to otg library
From: Kishon Vijay Abraham I @ 2013-01-16 15:01 UTC (permalink / raw)
  To: devicetree-discuss, linux-doc, linux-kernel, linux-omap,
	linux-arm-kernel, linux-usb, linux-sh, linuxppc-dev, balbi
  Cc: linux, b-cousson, tony, gregkh, rob.herring, kishon, cbou,
	alexander.shishkin, horms, stern, haojian.zhuang, rob,
	eric.y.miao, Marc Kleine-Budde, dwmw2
In-Reply-To: <1358348462-27693-1-git-send-email-kishon@ti.com>

Added an API devm_usb_get_phy_by_phandle(), to get usb phy by passing a
device node phandle value. This function will return a pointer to
the phy on success, -EPROBE_DEFER if there is a device_node for the phandle,
but the phy has not been added, or a ERR_PTR() otherwise.

Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/otg/otg.c   |   77 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/phy.h |    8 +++++
 2 files changed, 85 insertions(+)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index dbf2043..e9799bb 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -13,7 +13,9 @@
 #include <linux/export.h>
 #include <linux/err.h>
 #include <linux/device.h>
+#include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/of.h>
 
 #include <linux/usb/otg.h>
 
@@ -34,6 +36,20 @@ static struct usb_phy *__usb_find_phy(struct device *dev, u8 index)
 	return ERR_PTR(-ENODEV);
 }
 
+static struct usb_phy *__of_usb_find_phy(struct device_node *node)
+{
+	struct usb_phy  *phy;
+
+	list_for_each_entry(phy, &phy_list, head) {
+		if (node != phy->dev->of_node)
+			continue;
+
+		return phy;
+	}
+
+	return ERR_PTR(-ENODEV);
+}
+
 static void devm_usb_phy_release(struct device *dev, void *res)
 {
 	struct usb_phy *phy = *(struct usb_phy **)res;
@@ -109,6 +125,67 @@ err0:
 }
 EXPORT_SYMBOL(usb_get_phy);
 
+ /**
+ * devm_usb_get_phy_by_phandle - find the USB PHY by phandle
+ * @dev - device that requests this phy
+ * @phandle - name of the property holding the phy phandle value
+ * @index - the index of the phy
+ *
+ * Returns the phy driver associated with the given phandle value,
+ * after getting a refcount to it, -ENODEV if there is no such phy or
+ * -EPROBE_DEFER if there is a phandle to the phy, but the device is
+ * not yet loaded. While at that, it also associates the device with
+ * the phy using devres. On driver detach, release function is invoked
+ * on the devres data, then, devres data is freed.
+ *
+ * For use by USB host and peripheral drivers.
+ */
+struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
+	const char *phandle, u8 index)
+{
+	struct usb_phy	*phy = NULL, **ptr;
+	unsigned long	flags;
+	struct device_node *node;
+
+	if (!dev->of_node) {
+		dev_dbg(dev, "device does not have a device node entry\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	node = of_parse_phandle(dev->of_node, phandle, index);
+	if (!node) {
+		dev_dbg(dev, "failed to get %s phandle in %s node\n", phandle,
+			dev->of_node->full_name);
+		return ERR_PTR(-ENODEV);
+	}
+
+	ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
+	if (!ptr) {
+		dev_dbg(dev, "failed to allocate memory for devres\n");
+		return ERR_PTR(-ENOMEM);
+	}
+
+	spin_lock_irqsave(&phy_lock, flags);
+
+	phy = __of_usb_find_phy(node);
+	if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
+		phy = ERR_PTR(-EPROBE_DEFER);
+		devres_free(ptr);
+		goto err0;
+	}
+
+	*ptr = phy;
+	devres_add(dev, ptr);
+
+	get_device(phy->dev);
+
+err0:
+	spin_unlock_irqrestore(&phy_lock, flags);
+
+	return phy;
+}
+EXPORT_SYMBOL(devm_usb_get_phy_by_phandle);
+
 /**
  * devm_usb_put_phy - release the USB PHY
  * @dev - device that wants to release this phy
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index d133c8b..5836b6d 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -163,6 +163,8 @@ usb_phy_shutdown(struct usb_phy *x)
 #ifdef CONFIG_USB_OTG_UTILS
 extern struct usb_phy *usb_get_phy(struct device *dev, u8 index);
 extern struct usb_phy *devm_usb_get_phy(struct device *dev, u8 index);
+extern struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
+	const char *phandle, u8 index);
 extern void usb_put_phy(struct usb_phy *);
 extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x);
 extern struct usb_phy_bind *usb_bind_phy(const char *dev_name, u8 index,
@@ -178,6 +180,12 @@ static inline struct usb_phy *devm_usb_get_phy(struct device *dev, u8 index)
 	return NULL;
 }
 
+static inline struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
+	const char *phandle, u8 index)
+{
+	return NULL;
+}
+
 static inline void usb_put_phy(struct usb_phy *x)
 {
 }
-- 
1.7.9.5

^ permalink raw reply related

* [RFC PATCH 4/6] ARM: dts: OMAP: Add phandle to bind PHY with USB controller
From: Kishon Vijay Abraham I @ 2013-01-16 15:01 UTC (permalink / raw)
  To: devicetree-discuss, linux-doc, linux-kernel, linux-omap,
	linux-arm-kernel, linux-usb, linux-sh, linuxppc-dev, balbi
  Cc: linux, b-cousson, tony, gregkh, rob.herring, kishon, cbou,
	alexander.shishkin, horms, stern, haojian.zhuang, rob,
	eric.y.miao, dwmw2
In-Reply-To: <1358348462-27693-1-git-send-email-kishon@ti.com>

Added a phandle in the dt node for usb_otg to bind the PHY with the USB
controller and also updated the documentation with the binding information.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
I'll add this patch in this series "usb: musb: add driver for control module"
which contains the dt data to get MUSB working in dt boot in OMAP platforms.
 Documentation/devicetree/bindings/usb/omap-usb.txt |    2 ++
 arch/arm/boot/dts/omap3.dtsi                       |    1 +
 arch/arm/boot/dts/omap4.dtsi                       |    3 ++-
 arch/arm/boot/dts/twl4030.dtsi                     |    2 +-
 4 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 3f0152b..591c4fc 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -18,6 +18,7 @@ OMAP MUSB GLUE
    represents PERIPHERAL.
  - power : Should be "50". This signifies the controller can supply upto
    100mA when operating in host mode.
+ - usb_phy : the phandle for the PHY device
 
 SOC specific device node entry
 usb_otg_hs: usb_otg_hs@4a0ab000 {
@@ -27,6 +28,7 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
 	multipoint = <1>;
 	num_eps = <16>;
 	ram_bits = <12>;
+	usb_phy = <&phy>;
 };
 
 Board specific device node entry
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 8d03736..ebbf596 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -404,6 +404,7 @@
 			interrupts = <0 92 0x4>, <0 93 0x4>;
 			interrupt-names = "mc", "dma";
 			ti,hwmods = "usb_otg_hs";
+			usb_phy = <&phy>;
 			multipoint = <1>;
 			num_eps = <16>;
 			ram_bits = <12>;
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 5d770be..531cb2d 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -438,7 +438,7 @@
 			#size-cells = <1>;
 			ranges;
 			ti,hwmods = "ocp2scp_usb_phy";
-			usb2phy@4a0ad080 {
+			phy: usb2phy@4a0ad080 {
 				compatible = "ti,omap-usb2";
 				reg = <0x4a0ad080 0x58>;
 			};
@@ -540,6 +540,7 @@
 			interrupts = <0 92 0x4>, <0 93 0x4>;
 			interrupt-names = "mc", "dma";
 			ti,hwmods = "usb_otg_hs";
+			usb_phy = <&phy>;
 			multipoint = <1>;
 			num_eps = <16>;
 			ram_bits = <12>;
diff --git a/arch/arm/boot/dts/twl4030.dtsi b/arch/arm/boot/dts/twl4030.dtsi
index ed0bc95..80f7c2b 100644
--- a/arch/arm/boot/dts/twl4030.dtsi
+++ b/arch/arm/boot/dts/twl4030.dtsi
@@ -67,7 +67,7 @@
 		#interrupt-cells = <1>;
 	};
 
-	twl4030-usb {
+	phy: twl4030-usb {
 		compatible = "ti,twl4030-usb";
 		interrupts = <10>, <4>;
 		usb1v5-supply = <&vusb1v5>;
-- 
1.7.9.5

^ permalink raw reply related

* [RFC PATCH 3/6] usb: otg: utils: change the phy lib to support multiple PHYs of same type
From: Kishon Vijay Abraham I @ 2013-01-16 15:00 UTC (permalink / raw)
  To: devicetree-discuss, linux-doc, linux-kernel, linux-omap,
	linux-arm-kernel, linux-usb, linux-sh, linuxppc-dev, balbi
  Cc: linux, b-cousson, tony, gregkh, rob.herring, kishon, cbou,
	alexander.shishkin, horms, stern, haojian.zhuang, rob,
	eric.y.miao, dwmw2
In-Reply-To: <1358348462-27693-1-git-send-email-kishon@ti.com>

In order to add support for multipe PHY's of the same type, the API's
for adding PHY and getting PHY has been changed. Now the binding
information of the PHY and controller should be done in platform file
using usb_bind_phy API. And for getting a PHY, the device pointer of the
USB controller and an index should be passed. Based on the binding
information that is added in the platform file, get_phy will return the
approappropriate PHY.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 arch/arm/mach-shmobile/board-marzen.c |    2 +-
 drivers/power/ab8500_charger.c        |    2 +-
 drivers/power/isp1704_charger.c       |    2 +-
 drivers/power/pda_power.c             |    2 +-
 drivers/power/twl4030_charger.c       |    2 +-
 drivers/usb/chipidea/udc.c            |    2 +-
 drivers/usb/dwc3/core.c               |    4 +-
 drivers/usb/gadget/fsl_udc_core.c     |    2 +-
 drivers/usb/gadget/mv_udc_core.c      |    2 +-
 drivers/usb/gadget/omap_udc.c         |    2 +-
 drivers/usb/gadget/pxa25x_udc.c       |    2 +-
 drivers/usb/gadget/pxa27x_udc.c       |    2 +-
 drivers/usb/gadget/s3c-hsudc.c        |    2 +-
 drivers/usb/host/ehci-fsl.c           |    2 +-
 drivers/usb/host/ehci-msm.c           |    2 +-
 drivers/usb/host/ehci-mv.c            |    2 +-
 drivers/usb/host/ehci-tegra.c         |    2 +-
 drivers/usb/host/ohci-omap.c          |    2 +-
 drivers/usb/musb/am35x.c              |    2 +-
 drivers/usb/musb/blackfin.c           |    2 +-
 drivers/usb/musb/da8xx.c              |    2 +-
 drivers/usb/musb/davinci.c            |    2 +-
 drivers/usb/musb/musb_dsps.c          |    2 +-
 drivers/usb/musb/omap2430.c           |    2 +-
 drivers/usb/musb/tusb6010.c           |    2 +-
 drivers/usb/musb/ux500.c              |    2 +-
 drivers/usb/otg/ab8500-usb.c          |    3 +-
 drivers/usb/otg/fsl_otg.c             |    5 ++-
 drivers/usb/otg/gpio_vbus.c           |    3 +-
 drivers/usb/otg/isp1301_omap.c        |    3 +-
 drivers/usb/otg/msm_otg.c             |    3 +-
 drivers/usb/otg/mv_otg.c              |    3 +-
 drivers/usb/otg/nop-usb-xceiv.c       |    3 +-
 drivers/usb/otg/otg.c                 |   67 +++++++++++++++------------------
 drivers/usb/otg/twl4030-usb.c         |    3 +-
 drivers/usb/phy/mv_u3d_phy.c          |    3 +-
 drivers/usb/phy/omap-usb2.c           |   11 ++----
 drivers/usb/phy/rcar-phy.c            |    3 +-
 include/linux/usb/phy.h               |   12 +++---
 39 files changed, 87 insertions(+), 89 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-marzen.c b/arch/arm/mach-shmobile/board-marzen.c
index 449f928..abe482d 100644
--- a/arch/arm/mach-shmobile/board-marzen.c
+++ b/arch/arm/mach-shmobile/board-marzen.c
@@ -320,7 +320,7 @@ static struct platform_device *marzen_late_devices[] __initdata = {
 void __init marzen_init_late(void)
 {
 	/* get usb phy */
-	phy = usb_get_phy(USB_PHY_TYPE_USB2);
+	phy = usb_get_phy(&ehci0_device.dev, 0);
 
 	shmobile_init_late();
 	platform_add_devices(marzen_late_devices,
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index 3be9c0e..d20561a 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -2694,7 +2694,7 @@ static int ab8500_charger_probe(struct platform_device *pdev)
 		goto free_ac;
 	}
 
-	di->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2);
+	di->usb_phy = usb_get_phy(di->dev, 0);
 	if (IS_ERR_OR_NULL(di->usb_phy)) {
 		dev_err(di->dev, "failed to get usb transceiver\n");
 		ret = -EINVAL;
diff --git a/drivers/power/isp1704_charger.c b/drivers/power/isp1704_charger.c
index 176ad59..dfbe597 100644
--- a/drivers/power/isp1704_charger.c
+++ b/drivers/power/isp1704_charger.c
@@ -415,7 +415,7 @@ static int isp1704_charger_probe(struct platform_device *pdev)
 	if (!isp)
 		return -ENOMEM;
 
-	isp->phy = usb_get_phy(USB_PHY_TYPE_USB2);
+	isp->phy = usb_get_phy(&pdev->dev, 0);
 	if (IS_ERR_OR_NULL(isp->phy))
 		goto fail0;
 
diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
index 7df7c5f..64d79f7 100644
--- a/drivers/power/pda_power.c
+++ b/drivers/power/pda_power.c
@@ -316,7 +316,7 @@ static int pda_power_probe(struct platform_device *pdev)
 	}
 
 #ifdef CONFIG_USB_OTG_UTILS
-	transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+	transceiver = usb_get_phy(&pdev->dev, 0);
 	if (!IS_ERR_OR_NULL(transceiver)) {
 		if (!pdata->is_usb_online)
 			pdata->is_usb_online = otg_is_usb_online;
diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c
index a69d0d1..f53b417 100644
--- a/drivers/power/twl4030_charger.c
+++ b/drivers/power/twl4030_charger.c
@@ -552,7 +552,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
 
 	INIT_WORK(&bci->work, twl4030_bci_usb_work);
 
-	bci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+	bci->transceiver = usb_get_phy(&pdev->dev, 0);
 	if (!IS_ERR_OR_NULL(bci->transceiver)) {
 		bci->usb_nb.notifier_call = twl4030_bci_usb_ncb;
 		usb_register_notifier(bci->transceiver, &bci->usb_nb);
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 2f45bba..ea6a109 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1745,7 +1745,7 @@ static int udc_start(struct ci13xxx *ci)
 	ci->gadget.ep0 = &ci->ep0in->ep;
 
 	if (ci->global_phy)
-		ci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+		ci->transceiver = usb_get_phy(dev, 0);
 
 	if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
 		if (ci->transceiver == NULL) {
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 3a4004a..574d4b7 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -420,13 +420,13 @@ static int dwc3_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+	dwc->usb2_phy = devm_usb_get_phy(dev, 0);
 	if (IS_ERR_OR_NULL(dwc->usb2_phy)) {
 		dev_err(dev, "no usb2 phy configured\n");
 		return -EPROBE_DEFER;
 	}
 
-	dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
+	dwc->usb3_phy = devm_usb_get_phy(dev, 1);
 	if (IS_ERR_OR_NULL(dwc->usb3_phy)) {
 		dev_err(dev, "no usb3 phy configured\n");
 		return -EPROBE_DEFER;
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index c19f7f1..9c1a7a6 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -2456,7 +2456,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
 
 #ifdef CONFIG_USB_OTG
 	if (pdata->operating_mode == FSL_USB2_DR_OTG) {
-		udc_controller->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+		udc_controller->transceiver = usb_get_phy(&pdev->dev, 0);
 		if (IS_ERR_OR_NULL(udc_controller->transceiver)) {
 			ERR("Can't find OTG driver!\n");
 			ret = -ENODEV;
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index 379aac7..9aef556 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -2218,7 +2218,7 @@ static int mv_udc_probe(struct platform_device *dev)
 
 #ifdef CONFIG_USB_OTG_UTILS
 	if (pdata->mode == MV_USB_MODE_OTG)
-		udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+		udc->transceiver = usb_get_phy(&dev->dev, 0);
 #endif
 
 	udc->clknum = pdata->clknum;
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 8bfe990..5352ede 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2833,7 +2833,7 @@ static int omap_udc_probe(struct platform_device *pdev)
 		 * use it.  Except for OTG, we don't _need_ to talk to one;
 		 * but not having one probably means no VBUS detection.
 		 */
-		xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
+		xceiv = usb_get_phy(&pdev->dev, 0);
 		if (!IS_ERR_OR_NULL(xceiv))
 			type = xceiv->label;
 		else if (config->otg) {
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index d4ca9f1..666f2c0c 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -2157,7 +2157,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
 	dev->dev = &pdev->dev;
 	dev->mach = pdev->dev.platform_data;
 
-	dev->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+	dev->transceiver = usb_get_phy(dev->dev, 0);
 
 	if (gpio_is_valid(dev->mach->gpio_pullup)) {
 		if ((retval = gpio_request(dev->mach->gpio_pullup,
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 2b3b01d..844138c 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -2465,7 +2465,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev)
 
 	udc->dev = &pdev->dev;
 	udc->mach = pdev->dev.platform_data;
-	udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+	udc->transceiver = usb_get_phy(udc->dev, 0);
 
 	gpio = udc->mach->gpio_pullup;
 	if (gpio_is_valid(gpio)) {
diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c
index 52379b1..c1ca9f4 100644
--- a/drivers/usb/gadget/s3c-hsudc.c
+++ b/drivers/usb/gadget/s3c-hsudc.c
@@ -1281,7 +1281,7 @@ static int s3c_hsudc_probe(struct platform_device *pdev)
 	hsudc->dev = dev;
 	hsudc->pd = pdev->dev.platform_data;
 
-	hsudc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+	hsudc->transceiver = usb_get_phy(hsudc->dev, 0);
 
 	for (i = 0; i < ARRAY_SIZE(hsudc->supplies); i++)
 		hsudc->supplies[i].supply = s3c_hsudc_supply_names[i];
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index fd9b542..517df2e 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -143,7 +143,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
 	if (pdata->operating_mode == FSL_USB2_DR_OTG) {
 		struct ehci_hcd *ehci = hcd_to_ehci(hcd);
 
-		hcd->phy = usb_get_phy(USB_PHY_TYPE_USB2);
+		hcd->phy = usb_get_phy(&pdev->dev, 0);
 		dev_dbg(&pdev->dev, "hcd=0x%p  ehci=0x%p, phy=0x%p\n",
 			hcd, ehci, hcd->phy);
 
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index 88a49c8..39abbdb 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -144,7 +144,7 @@ static int ehci_msm_probe(struct platform_device *pdev)
 	 * powering up VBUS, mapping of registers address space and power
 	 * management.
 	 */
-	phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
+	phy = devm_usb_get_phy(&pdev->dev, 0);
 	if (IS_ERR_OR_NULL(phy)) {
 		dev_err(&pdev->dev, "unable to find transceiver\n");
 		ret = -ENODEV;
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index f7bfc0b..6316950 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -241,7 +241,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	ehci_mv->mode = pdata->mode;
 	if (ehci_mv->mode == MV_USB_MODE_OTG) {
 #ifdef CONFIG_USB_OTG_UTILS
-		ehci_mv->otg = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
+		ehci_mv->otg = devm_usb_get_phy(&pdev->dev, 0);
 		if (IS_ERR_OR_NULL(ehci_mv->otg)) {
 			dev_err(&pdev->dev,
 				"unable to find transceiver\n");
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index acf1755..7a081df 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -733,7 +733,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
 #ifdef CONFIG_USB_OTG_UTILS
 	if (pdata->operating_mode == TEGRA_USB_OTG) {
 		tegra->transceiver =
-			devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
+			devm_usb_get_phy(&pdev->dev, 0);
 		if (!IS_ERR_OR_NULL(tegra->transceiver))
 			otg_set_host(tegra->transceiver->otg, &hcd->self);
 	}
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index b1d32fb..bd823d2 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -213,7 +213,7 @@ static int ohci_omap_init(struct usb_hcd *hcd)
 
 #ifdef	CONFIG_USB_OTG
 	if (need_transceiver) {
-		hcd->phy = usb_get_phy(USB_PHY_TYPE_USB2);
+		hcd->phy = usb_get_phy(hcd->self.controller, 0);
 		if (!IS_ERR_OR_NULL(hcd->phy)) {
 			int	status = otg_set_host(hcd->phy->otg,
 						&ohci_to_hcd(ohci)->self);
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index c107d7c..b7a8c94 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -363,7 +363,7 @@ static int am35x_musb_init(struct musb *musb)
 		return -ENODEV;
 
 	usb_nop_xceiv_register();
-	musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
+	musb->xceiv = usb_get_phy(dev, 0);
 	if (IS_ERR_OR_NULL(musb->xceiv))
 		return -ENODEV;
 
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 14dab9f..596bc5b 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -403,7 +403,7 @@ static int bfin_musb_init(struct musb *musb)
 	gpio_direction_output(musb->config->gpio_vrsel, 0);
 
 	usb_nop_xceiv_register();
-	musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
+	musb->xceiv = usb_get_phy(musb->controller, 0);
 	if (IS_ERR_OR_NULL(musb->xceiv)) {
 		gpio_free(musb->config->gpio_vrsel);
 		return -ENODEV;
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 97996af..a01844e 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -419,7 +419,7 @@ static int da8xx_musb_init(struct musb *musb)
 		goto fail;
 
 	usb_nop_xceiv_register();
-	musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
+	musb->xceiv = usb_get_phy(musb->controller, 0);
 	if (IS_ERR_OR_NULL(musb->xceiv))
 		goto fail;
 
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index b1c01ca..66aa3f0 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -382,7 +382,7 @@ static int davinci_musb_init(struct musb *musb)
 	u32		revision;
 
 	usb_nop_xceiv_register();
-	musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
+	musb->xceiv = usb_get_phy(musb->controller, 0);
 	if (IS_ERR_OR_NULL(musb->xceiv))
 		goto unregister;
 
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index e6f2ae8..d71cbf5 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -412,7 +412,7 @@ static int dsps_musb_init(struct musb *musb)
 
 	/* NOP driver needs change if supporting dual instance */
 	usb_nop_xceiv_register();
-	musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
+	musb->xceiv = usb_get_phy(dev, 0);
 	if (IS_ERR_OR_NULL(musb->xceiv))
 		return -ENODEV;
 
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 3e7ceef..3628a50 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -346,7 +346,7 @@ static int omap2430_musb_init(struct musb *musb)
 	 * up through ULPI.  TWL4030-family PMICs include one,
 	 * which needs a driver, drivers aren't always needed.
 	 */
-	musb->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+	musb->xceiv = devm_usb_get_phy(dev, 0);
 	if (IS_ERR_OR_NULL(musb->xceiv)) {
 		pr_err("HS USB OTG: no transceiver configured\n");
 		return -ENODEV;
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 3969813..02338f6 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -1067,7 +1067,7 @@ static int tusb_musb_init(struct musb *musb)
 	int			ret;
 
 	usb_nop_xceiv_register();
-	musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
+	musb->xceiv = usb_get_phy(musb->controller, 0);
 	if (IS_ERR_OR_NULL(musb->xceiv))
 		return -ENODEV;
 
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index a27ca1a..5affcf7 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -58,7 +58,7 @@ static irqreturn_t ux500_musb_interrupt(int irq, void *__hci)
 
 static int ux500_musb_init(struct musb *musb)
 {
-	musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
+	musb->xceiv = usb_get_phy(musb->controller, 0);
 	if (IS_ERR_OR_NULL(musb->xceiv)) {
 		pr_err("HS USB OTG: no transceiver configured\n");
 		return -ENODEV;
diff --git a/drivers/usb/otg/ab8500-usb.c b/drivers/usb/otg/ab8500-usb.c
index 2d86f26..07aeb8c 100644
--- a/drivers/usb/otg/ab8500-usb.c
+++ b/drivers/usb/otg/ab8500-usb.c
@@ -502,6 +502,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
 	ab->phy.set_suspend	= ab8500_usb_set_suspend;
 	ab->phy.set_power	= ab8500_usb_set_power;
 	ab->phy.state		= OTG_STATE_UNDEFINED;
+	ab->phy.type		= USB_PHY_TYPE_USB2;
 
 	otg->phy		= &ab->phy;
 	otg->set_host		= ab8500_usb_set_host;
@@ -529,7 +530,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
 	if (err < 0)
 		goto fail0;
 
-	err = usb_add_phy(&ab->phy, USB_PHY_TYPE_USB2);
+	err = usb_add_phy(&ab->phy);
 	if (err) {
 		dev_err(&pdev->dev, "Can't register transceiver\n");
 		goto fail1;
diff --git a/drivers/usb/otg/fsl_otg.c b/drivers/usb/otg/fsl_otg.c
index d16adb4..ae6d3f5 100644
--- a/drivers/usb/otg/fsl_otg.c
+++ b/drivers/usb/otg/fsl_otg.c
@@ -810,6 +810,7 @@ static int fsl_otg_conf(struct platform_device *pdev)
 	/* initialize the otg structure */
 	fsl_otg_tc->phy.label = DRIVER_DESC;
 	fsl_otg_tc->phy.set_power = fsl_otg_set_power;
+	fsl_otg_tc->phy.type = USB_PHY_TYPE_USB2;
 
 	fsl_otg_tc->phy.otg->phy = &fsl_otg_tc->phy;
 	fsl_otg_tc->phy.otg->set_host = fsl_otg_set_host;
@@ -820,7 +821,7 @@ static int fsl_otg_conf(struct platform_device *pdev)
 	fsl_otg_dev = fsl_otg_tc;
 
 	/* Store the otg transceiver */
-	status = usb_add_phy(&fsl_otg_tc->phy, USB_PHY_TYPE_USB2);
+	status = usb_add_phy(&fsl_otg_tc->phy);
 	if (status) {
 		pr_warn(FSL_OTG_NAME ": unable to register OTG transceiver.\n");
 		goto err;
@@ -838,7 +839,7 @@ err:
 int usb_otg_start(struct platform_device *pdev)
 {
 	struct fsl_otg *p_otg;
-	struct usb_phy *otg_trans = usb_get_phy(USB_PHY_TYPE_USB2);
+	struct usb_phy *otg_trans = usb_get_phy(&pdev->dev, 0);
 	struct otg_fsm *fsm;
 	int status;
 	struct resource *res;
diff --git a/drivers/usb/otg/gpio_vbus.c b/drivers/usb/otg/gpio_vbus.c
index a67ffe2..815e8dc 100644
--- a/drivers/usb/otg/gpio_vbus.c
+++ b/drivers/usb/otg/gpio_vbus.c
@@ -264,6 +264,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
 	gpio_vbus->phy.set_power = gpio_vbus_set_power;
 	gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend;
 	gpio_vbus->phy.state = OTG_STATE_UNDEFINED;
+	gpio_vbus->phy.type = USB_PHY_TYPE_USB2;
 
 	gpio_vbus->phy.otg->phy = &gpio_vbus->phy;
 	gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;
@@ -320,7 +321,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
 	}
 
 	/* only active when a gadget is registered */
-	err = usb_add_phy(&gpio_vbus->phy, USB_PHY_TYPE_USB2);
+	err = usb_add_phy(&gpio_vbus->phy);
 	if (err) {
 		dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
 			err);
diff --git a/drivers/usb/otg/isp1301_omap.c b/drivers/usb/otg/isp1301_omap.c
index af9cb11..c85b309 100644
--- a/drivers/usb/otg/isp1301_omap.c
+++ b/drivers/usb/otg/isp1301_omap.c
@@ -1587,6 +1587,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
 	isp->phy.dev = &i2c->dev;
 	isp->phy.label = DRIVER_NAME;
 	isp->phy.set_power = isp1301_set_power,
+	isp->phy.type = USB_PHY_TYPE_USB2,
 
 	isp->phy.otg->phy = &isp->phy;
 	isp->phy.otg->set_host = isp1301_set_host,
@@ -1610,7 +1611,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
 	dev_dbg(&i2c->dev, "scheduled timer, %d min\n", TIMER_MINUTES);
 #endif
 
-	status = usb_add_phy(&isp->phy, USB_PHY_TYPE_USB2);
+	status = usb_add_phy(&isp->phy);
 	if (status < 0)
 		dev_err(&i2c->dev, "can't register transceiver, %d\n",
 			status);
diff --git a/drivers/usb/otg/msm_otg.c b/drivers/usb/otg/msm_otg.c
index 3b9f0d9..5376d84 100644
--- a/drivers/usb/otg/msm_otg.c
+++ b/drivers/usb/otg/msm_otg.c
@@ -1548,6 +1548,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
 
 	phy->init = msm_otg_reset;
 	phy->set_power = msm_otg_set_power;
+	phy->phy_type = USB_PHY_TYPE_USB2;
 
 	phy->io_ops = &msm_otg_io_ops;
 
@@ -1555,7 +1556,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
 	phy->otg->set_host = msm_otg_set_host;
 	phy->otg->set_peripheral = msm_otg_set_peripheral;
 
-	ret = usb_add_phy(&motg->phy, USB_PHY_TYPE_USB2);
+	ret = usb_add_phy(&motg->phy);
 	if (ret) {
 		dev_err(&pdev->dev, "usb_add_phy failed\n");
 		goto free_irq;
diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c
index 1dd5750..2167e41 100644
--- a/drivers/usb/otg/mv_otg.c
+++ b/drivers/usb/otg/mv_otg.c
@@ -755,6 +755,7 @@ static int mv_otg_probe(struct platform_device *pdev)
 	mvotg->phy.otg = otg;
 	mvotg->phy.label = driver_name;
 	mvotg->phy.state = OTG_STATE_UNDEFINED;
+	mvotg->phy.type = USB_PHY_TYPE_USB2;
 
 	otg->phy = &mvotg->phy;
 	otg->set_host = mv_otg_set_host;
@@ -853,7 +854,7 @@ static int mv_otg_probe(struct platform_device *pdev)
 		goto err_disable_clk;
 	}
 
-	retval = usb_add_phy(&mvotg->phy, USB_PHY_TYPE_USB2);
+	retval = usb_add_phy(&mvotg->phy);
 	if (retval < 0) {
 		dev_err(&pdev->dev, "can't register transceiver, %d\n",
 			retval);
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index a3ce24b..d8d72f6 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -118,12 +118,13 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
 	nop->phy.label		= "nop-xceiv";
 	nop->phy.set_suspend	= nop_set_suspend;
 	nop->phy.state		= OTG_STATE_UNDEFINED;
+	nop->phy.type		= type;
 
 	nop->phy.otg->phy		= &nop->phy;
 	nop->phy.otg->set_host		= nop_set_host;
 	nop->phy.otg->set_peripheral	= nop_set_peripheral;
 
-	err = usb_add_phy(&nop->phy, type);
+	err = usb_add_phy(&nop->phy);
 	if (err) {
 		dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
 			err);
diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index 492ba2f..dbf2043 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -21,16 +21,14 @@ static LIST_HEAD(phy_list);
 static LIST_HEAD(phy_bind_list);
 static DEFINE_SPINLOCK(phy_lock);
 
-static struct usb_phy *__usb_find_phy(struct list_head *list,
-	enum usb_phy_type type)
+static struct usb_phy *__usb_find_phy(struct device *dev, u8 index)
 {
-	struct usb_phy  *phy = NULL;
+	struct usb_phy_bind *phy_bind = NULL;
 
-	list_for_each_entry(phy, list, head) {
-		if (phy->type != type)
-			continue;
-
-		return phy;
+	list_for_each_entry(phy_bind, &phy_bind_list, list) {
+		if (!(strcmp(phy_bind->dev_name, dev_name(dev))) &&
+				phy_bind->index == index)
+			return phy_bind->phy;
 	}
 
 	return ERR_PTR(-ENODEV);
@@ -51,7 +49,7 @@ static int devm_usb_phy_match(struct device *dev, void *res, void *match_data)
 /**
  * devm_usb_get_phy - find the USB PHY
  * @dev - device that requests this phy
- * @type - the type of the phy the controller requires
+ * @index - the index of the phy
  *
  * Gets the phy using usb_get_phy(), and associates a device with it using
  * devres. On driver detach, release function is invoked on the devres data,
@@ -59,7 +57,7 @@ static int devm_usb_phy_match(struct device *dev, void *res, void *match_data)
  *
  * For use by USB host and peripheral drivers.
  */
-struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type)
+struct usb_phy *devm_usb_get_phy(struct device *dev, u8 index)
 {
 	struct usb_phy **ptr, *phy;
 
@@ -67,7 +65,7 @@ struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type)
 	if (!ptr)
 		return NULL;
 
-	phy = usb_get_phy(type);
+	phy = usb_get_phy(dev, index);
 	if (!IS_ERR(phy)) {
 		*ptr = phy;
 		devres_add(dev, ptr);
@@ -80,7 +78,8 @@ EXPORT_SYMBOL(devm_usb_get_phy);
 
 /**
  * usb_get_phy - find the USB PHY
- * @type - the type of the phy the controller requires
+ * @dev - device that requests this phy
+ * @index - the index of the phy
  *
  * Returns the phy driver, after getting a refcount to it; or
  * -ENODEV if there is no such phy.  The caller is responsible for
@@ -88,17 +87,16 @@ EXPORT_SYMBOL(devm_usb_get_phy);
  *
  * For use by USB host and peripheral drivers.
  */
-struct usb_phy *usb_get_phy(enum usb_phy_type type)
+struct usb_phy *usb_get_phy(struct device *dev, u8 index)
 {
 	struct usb_phy	*phy = NULL;
 	unsigned long	flags;
 
 	spin_lock_irqsave(&phy_lock, flags);
 
-	phy = __usb_find_phy(&phy_list, type);
+	phy = __usb_find_phy(dev, index);
 	if (IS_ERR(phy)) {
-		pr_err("unable to find transceiver of type %s\n",
-			usb_phy_type_string(type));
+		pr_err("unable to find phy\n");
 		goto err0;
 	}
 
@@ -148,40 +146,30 @@ EXPORT_SYMBOL(usb_put_phy);
 /**
  * usb_add_phy - declare the USB PHY
  * @x: the USB phy to be used; or NULL
- * @type - the type of this PHY
  *
  * This call is exclusively for use by phy drivers, which
  * coordinate the activities of drivers for host and peripheral
  * controllers, and in some cases for VBUS current regulation.
  */
-int usb_add_phy(struct usb_phy *x, enum usb_phy_type type)
+int usb_add_phy(struct usb_phy *x)
 {
-	int		ret = 0;
-	unsigned long	flags;
-	struct usb_phy	*phy;
+	struct usb_phy_bind *phy_bind;
+	unsigned long flags;
 
-	if (x->type != USB_PHY_TYPE_UNDEFINED) {
-		dev_err(x->dev, "not accepting initialized PHY %s\n", x->label);
+	if (!x->dev) {
+		dev_err(x->dev, "no device provided for PHY\n");
 		return -EINVAL;
 	}
 
 	spin_lock_irqsave(&phy_lock, flags);
+	list_for_each_entry(phy_bind, &phy_bind_list, list)
+		if (!(strcmp(phy_bind->phy_dev_name, dev_name(x->dev))))
+			phy_bind->phy = x;
 
-	list_for_each_entry(phy, &phy_list, head) {
-		if (phy->type == type) {
-			ret = -EBUSY;
-			dev_err(x->dev, "transceiver type %s already exists\n",
-						usb_phy_type_string(type));
-			goto out;
-		}
-	}
-
-	x->type = type;
 	list_add_tail(&x->head, &phy_list);
-
-out:
 	spin_unlock_irqrestore(&phy_lock, flags);
-	return ret;
+
+	return 0;
 }
 EXPORT_SYMBOL(usb_add_phy);
 
@@ -194,10 +182,15 @@ EXPORT_SYMBOL(usb_add_phy);
 void usb_remove_phy(struct usb_phy *x)
 {
 	unsigned long	flags;
+	struct usb_phy_bind *phy_bind;
 
 	spin_lock_irqsave(&phy_lock, flags);
-	if (x)
+	if (x) {
+		list_for_each_entry(phy_bind, &phy_bind_list, list)
+			if (phy_bind->phy == x)
+				phy_bind->phy = NULL;
 		list_del(&x->head);
+	}
 	spin_unlock_irqrestore(&phy_lock, flags);
 }
 EXPORT_SYMBOL(usb_remove_phy);
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
index 0a70193..f6bdd75 100644
--- a/drivers/usb/otg/twl4030-usb.c
+++ b/drivers/usb/otg/twl4030-usb.c
@@ -611,6 +611,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
 	twl->phy.label		= "twl4030";
 	twl->phy.otg		= otg;
 	twl->phy.set_suspend	= twl4030_set_suspend;
+	twl->phy.type		= USB_PHY_TYPE_USB2;
 
 	otg->phy		= &twl->phy;
 	otg->set_host		= twl4030_set_host;
@@ -624,7 +625,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "ldo init failed\n");
 		return err;
 	}
-	usb_add_phy(&twl->phy, USB_PHY_TYPE_USB2);
+	usb_add_phy(&twl->phy);
 
 	platform_set_drvdata(pdev, twl);
 	if (device_create_file(&pdev->dev, &dev_attr_vbus))
diff --git a/drivers/usb/phy/mv_u3d_phy.c b/drivers/usb/phy/mv_u3d_phy.c
index eaddbe3..31a19a3 100644
--- a/drivers/usb/phy/mv_u3d_phy.c
+++ b/drivers/usb/phy/mv_u3d_phy.c
@@ -298,10 +298,11 @@ static int mv_u3d_phy_probe(struct platform_device *pdev)
 	mv_u3d_phy->base		= phy_base;
 	mv_u3d_phy->phy.dev		= mv_u3d_phy->dev;
 	mv_u3d_phy->phy.label		= "mv-u3d-phy";
+	mv_u3d_phy->phy.type		= USB_PHY_TYPE_USB3;
 	mv_u3d_phy->phy.init		= mv_u3d_phy_init;
 	mv_u3d_phy->phy.shutdown	= mv_u3d_phy_shutdown;
 
-	ret = usb_add_phy(&mv_u3d_phy->phy, USB_PHY_TYPE_USB3);
+	ret = usb_add_phy(&mv_u3d_phy->phy);
 	if (ret)
 		goto err;
 
diff --git a/drivers/usb/phy/omap-usb2.c b/drivers/usb/phy/omap-usb2.c
index 2152ce4..0e7636f 100644
--- a/drivers/usb/phy/omap-usb2.c
+++ b/drivers/usb/phy/omap-usb2.c
@@ -29,6 +29,7 @@
 #include <linux/delay.h>
 #include <linux/usb/omap_control_usb.h>
 
+static struct omap_usb	*phy;
 /**
  * omap_usb2_set_comparator - links the comparator present in the sytem with
  *	this phy
@@ -41,13 +42,9 @@
  */
 int omap_usb2_set_comparator(struct phy_companion *comparator)
 {
-	struct omap_usb	*phy;
-	struct usb_phy	*x = usb_get_phy(USB_PHY_TYPE_USB2);
-
-	if (IS_ERR(x))
+	if (!phy)
 		return -ENODEV;
 
-	phy = phy_to_omapusb(x);
 	phy->comparator = comparator;
 	return 0;
 }
@@ -121,7 +118,6 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend)
 
 static int omap_usb2_probe(struct platform_device *pdev)
 {
-	struct omap_usb			*phy;
 	struct usb_otg			*otg;
 	struct resource			*res;
 
@@ -141,6 +137,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
 	phy->phy.dev		= phy->dev;
 	phy->phy.label		= "omap-usb2";
+	phy->phy.type		= USB_PHY_TYPE_USB2;
 	phy->phy.set_suspend	= omap_usb2_suspend;
 	phy->phy.otg		= otg;
 
@@ -168,7 +165,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	}
 	clk_prepare(phy->wkupclk);
 
-	usb_add_phy(&phy->phy, USB_PHY_TYPE_USB2);
+	usb_add_phy(&phy->phy);
 
 	platform_set_drvdata(pdev, phy);
 
diff --git a/drivers/usb/phy/rcar-phy.c b/drivers/usb/phy/rcar-phy.c
index a35681b..bd00fd9 100644
--- a/drivers/usb/phy/rcar-phy.c
+++ b/drivers/usb/phy/rcar-phy.c
@@ -181,11 +181,12 @@ static int rcar_usb_phy_probe(struct platform_device *pdev)
 	priv->counter		= 0;
 	priv->phy.dev		= dev;
 	priv->phy.label		= dev_name(dev);
+	priv->phy.type		= USB_PHY_TYPE_USB2;
 	priv->phy.init		= rcar_usb_phy_init;
 	priv->phy.shutdown	= rcar_usb_phy_shutdown;
 	spin_lock_init(&priv->lock);
 
-	ret = usb_add_phy(&priv->phy, USB_PHY_TYPE_USB2);
+	ret = usb_add_phy(&priv->phy);
 	if (ret < 0) {
 		dev_err(dev, "usb phy addition error\n");
 		return ret;
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index fbeab1a..d133c8b 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -123,7 +123,7 @@ struct usb_phy_bind {
 };
 
 /* for board-specific init logic */
-extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type);
+extern int usb_add_phy(struct usb_phy *);
 extern void usb_remove_phy(struct usb_phy *);
 
 /* helpers for direct access thru low-level io interface */
@@ -161,21 +161,19 @@ usb_phy_shutdown(struct usb_phy *x)
 
 /* for usb host and peripheral controller drivers */
 #ifdef CONFIG_USB_OTG_UTILS
-extern struct usb_phy *usb_get_phy(enum usb_phy_type type);
-extern struct usb_phy *devm_usb_get_phy(struct device *dev,
-	enum usb_phy_type type);
+extern struct usb_phy *usb_get_phy(struct device *dev, u8 index);
+extern struct usb_phy *devm_usb_get_phy(struct device *dev, u8 index);
 extern void usb_put_phy(struct usb_phy *);
 extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x);
 extern struct usb_phy_bind *usb_bind_phy(const char *dev_name, u8 index,
 				const char *phy_dev_name);
 #else
-static inline struct usb_phy *usb_get_phy(enum usb_phy_type type)
+static inline struct usb_phy *usb_get_phy(struct device *dev, u8 index)
 {
 	return NULL;
 }
 
-static inline struct usb_phy *devm_usb_get_phy(struct device *dev,
-	enum usb_phy_type type)
+static inline struct usb_phy *devm_usb_get_phy(struct device *dev, u8 index)
 {
 	return NULL;
 }
-- 
1.7.9.5

^ permalink raw reply related

* [RFC PATCH 2/6] ARM: OMAP: USB: Add phy binding information
From: Kishon Vijay Abraham I @ 2013-01-16 15:00 UTC (permalink / raw)
  To: devicetree-discuss, linux-doc, linux-kernel, linux-omap,
	linux-arm-kernel, linux-usb, linux-sh, linuxppc-dev, balbi
  Cc: linux, b-cousson, tony, gregkh, rob.herring, kishon, cbou,
	alexander.shishkin, horms, stern, haojian.zhuang, rob,
	eric.y.miao, dwmw2
In-Reply-To: <1358348462-27693-1-git-send-email-kishon@ti.com>

This is in preparation for the changes in PHY library to support adding
and getting multiple PHYs of the same type. In the new design, the
binding information between the PHY and the USB controller should be
specified in the platform specific initialization code. So it's been
done for OMAP platforms here.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
This kind-of binding should be done in all the platforms (I've done only
for OMAP platform). 
 arch/arm/mach-omap2/usb-musb.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 9d27e3f..bbe2fa5 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -24,6 +24,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
 #include <linux/usb/musb.h>
+#include <linux/usb/phy.h>
 
 #include "omap_device.h"
 #include "soc.h"
@@ -85,8 +86,12 @@ void __init usb_musb_init(struct omap_musb_board_data *musb_board_data)
 	musb_plat.mode = board_data->mode;
 	musb_plat.extvbus = board_data->extvbus;
 
-	if (cpu_is_omap44xx())
+	if (cpu_is_omap44xx()) {
 		musb_plat.has_mailbox = true;
+		usb_bind_phy("musb-hdrc.0.auto", 0, "omap-usb2.1.auto");
+	} else if (cpu_is_omap34xx()) {
+		usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+	}
 
 	if (soc_is_am35xx()) {
 		oh_name = "am35x_otg_hs";
-- 
1.7.9.5

^ permalink raw reply related

* [RFC PATCH 1/6] usb: otg: Add an API to bind the USB controller and PHY
From: Kishon Vijay Abraham I @ 2013-01-16 15:00 UTC (permalink / raw)
  To: devicetree-discuss, linux-doc, linux-kernel, linux-omap,
	linux-arm-kernel, linux-usb, linux-sh, linuxppc-dev, balbi
  Cc: linux, b-cousson, tony, gregkh, rob.herring, kishon, cbou,
	alexander.shishkin, horms, stern, haojian.zhuang, rob,
	eric.y.miao, dwmw2
In-Reply-To: <1358348462-27693-1-git-send-email-kishon@ti.com>

New platforms are added which has multiple PHY's (of same type) and
which has multiple USB controllers. The binding information has to be
present in the PHY library (otg.c) in order for it to return the
appropriate PHY whenever the USB controller request for the PHY. So
added a new API to pass the binding information. This API should be
called by platform specific initialization code.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/otg/otg.c   |   37 +++++++++++++++++++++++++++++++++++++
 include/linux/usb/phy.h |   22 ++++++++++++++++++++++
 2 files changed, 59 insertions(+)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index a30c041..492ba2f 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -18,6 +18,7 @@
 #include <linux/usb/otg.h>
 
 static LIST_HEAD(phy_list);
+static LIST_HEAD(phy_bind_list);
 static DEFINE_SPINLOCK(phy_lock);
 
 static struct usb_phy *__usb_find_phy(struct list_head *list,
@@ -201,6 +202,42 @@ void usb_remove_phy(struct usb_phy *x)
 }
 EXPORT_SYMBOL(usb_remove_phy);
 
+/**
+ * usb_bind_phy - bind the phy and the controller that uses the phy
+ * @dev_name: the device name of the device that will bind to the phy
+ * @index: index to specify the port number
+ * @phy_dev_name: the device name of the phy
+ *
+ * Fills the phy_bind structure with the dev_name and phy_dev_name. This will
+ * be used when the phy driver registers the phy and when the controller
+ * requests this phy.
+ *
+ * To be used by platform specific initialization code.
+ */
+struct usb_phy_bind __init *usb_bind_phy(const char *dev_name, u8 index,
+				const char *phy_dev_name)
+{
+	struct usb_phy_bind *phy_bind;
+	unsigned long flags;
+
+	phy_bind = kzalloc(sizeof(*phy_bind), GFP_KERNEL);
+	if (!phy_bind) {
+		pr_err("phy_bind(): No memory for phy_bind");
+		return ERR_PTR(-ENOMEM);
+	}
+
+	phy_bind->dev_name = dev_name;
+	phy_bind->phy_dev_name = phy_dev_name;
+	phy_bind->index = index;
+
+	spin_lock_irqsave(&phy_lock, flags);
+	list_add_tail(&phy_bind->list, &phy_bind_list);
+	spin_unlock_irqrestore(&phy_lock, flags);
+
+	return phy_bind;
+}
+EXPORT_SYMBOL_GPL(usb_bind_phy);
+
 const char *otg_state_string(enum usb_otg_state state)
 {
 	switch (state) {
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index a29ae1e..fbeab1a 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -106,6 +106,21 @@ struct usb_phy {
 			enum usb_device_speed speed);
 };
 
+/**
+ * struct usb_phy_bind - represent the binding for the phy
+ * @dev_name: the device name of the device that will bind to the phy
+ * @phy_dev_name: the device name of the phy
+ * @index: used if a single controller uses multiple phys
+ * @phy: reference to the phy
+ * @list: to maintain a linked list of the binding information
+ */
+struct usb_phy_bind {
+	const char	*dev_name;
+	const char	*phy_dev_name;
+	u8		index;
+	struct usb_phy	*phy;
+	struct list_head list;
+};
 
 /* for board-specific init logic */
 extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type);
@@ -151,6 +166,8 @@ extern struct usb_phy *devm_usb_get_phy(struct device *dev,
 	enum usb_phy_type type);
 extern void usb_put_phy(struct usb_phy *);
 extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x);
+extern struct usb_phy_bind *usb_bind_phy(const char *dev_name, u8 index,
+				const char *phy_dev_name);
 #else
 static inline struct usb_phy *usb_get_phy(enum usb_phy_type type)
 {
@@ -171,6 +188,11 @@ static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x)
 {
 }
 
+static inline struct usb_phy_bind *usb_bind_phy(const char *dev_name, u8 index,
+				const char *phy_dev_name)
+{
+	return NULL;
+}
 #endif
 
 static inline int
-- 
1.7.9.5

^ permalink raw reply related

* [RFC PATCH 0/6] USB: Add multiple PHYs of same type
From: Kishon Vijay Abraham I @ 2013-01-16 15:00 UTC (permalink / raw)
  To: devicetree-discuss, linux-doc, linux-kernel, linux-omap,
	linux-arm-kernel, linux-usb, linux-sh, linuxppc-dev, balbi
  Cc: linux, b-cousson, tony, gregkh, rob.herring, kishon, cbou,
	alexander.shishkin, horms, stern, haojian.zhuang, rob,
	eric.y.miao, dwmw2

New platforms are being added which has multiple PHY's (of same type) and
which has multiple USB controllers. The binding information has to be
present in the PHY library (otg.c) in order for it to return the
appropriate PHY whenever the USB controller request for the PHY. So
added a new API to pass the binding information. This API should be
called by platform specific initialization code.

So the binding should be done something like
usb_bind_phy("musb-hdrc.0.auto", 0, "omap-usb2.1.auto"); specifying the USB
controller device name, index, and the PHY device name.
I have done this binding for OMAP platforms, but it should be done for
all the platforms.

After this design, the phy can be got by passing the USB controller device
pointer and the index.

Developed this patch series on
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git xceiv
after applying "usb: musb: add driver for control module" patch series.

Did basic enumeration testing in omap4 panda, omap4 sdp and omap3 beagle.

Kishon Vijay Abraham I (6):
  usb: otg: Add an API to bind the USB controller and PHY
  ARM: OMAP: USB: Add phy binding information
  usb: otg: utils: change the phy lib to support multiple PHYs of same
    type
  ARM: dts: OMAP: Add phandle to bind PHY with USB controller
  usb: otg: add device tree support to otg library
  USB: MUSB: OMAP: get PHY by phandle for dt boot

 Documentation/devicetree/bindings/usb/omap-usb.txt |    2 +
 arch/arm/boot/dts/omap3.dtsi                       |    1 +
 arch/arm/boot/dts/omap4.dtsi                       |    3 +-
 arch/arm/boot/dts/twl4030.dtsi                     |    2 +-
 arch/arm/mach-omap2/usb-musb.c                     |    7 +-
 arch/arm/mach-shmobile/board-marzen.c              |    2 +-
 drivers/power/ab8500_charger.c                     |    2 +-
 drivers/power/isp1704_charger.c                    |    2 +-
 drivers/power/pda_power.c                          |    2 +-
 drivers/power/twl4030_charger.c                    |    2 +-
 drivers/usb/chipidea/udc.c                         |    2 +-
 drivers/usb/dwc3/core.c                            |    4 +-
 drivers/usb/gadget/fsl_udc_core.c                  |    2 +-
 drivers/usb/gadget/mv_udc_core.c                   |    2 +-
 drivers/usb/gadget/omap_udc.c                      |    2 +-
 drivers/usb/gadget/pxa25x_udc.c                    |    2 +-
 drivers/usb/gadget/pxa27x_udc.c                    |    2 +-
 drivers/usb/gadget/s3c-hsudc.c                     |    2 +-
 drivers/usb/host/ehci-fsl.c                        |    2 +-
 drivers/usb/host/ehci-msm.c                        |    2 +-
 drivers/usb/host/ehci-mv.c                         |    2 +-
 drivers/usb/host/ehci-tegra.c                      |    2 +-
 drivers/usb/host/ohci-omap.c                       |    2 +-
 drivers/usb/musb/am35x.c                           |    2 +-
 drivers/usb/musb/blackfin.c                        |    2 +-
 drivers/usb/musb/da8xx.c                           |    2 +-
 drivers/usb/musb/davinci.c                         |    2 +-
 drivers/usb/musb/musb_dsps.c                       |    2 +-
 drivers/usb/musb/omap2430.c                        |    7 +-
 drivers/usb/musb/tusb6010.c                        |    2 +-
 drivers/usb/musb/ux500.c                           |    2 +-
 drivers/usb/otg/ab8500-usb.c                       |    3 +-
 drivers/usb/otg/fsl_otg.c                          |    5 +-
 drivers/usb/otg/gpio_vbus.c                        |    3 +-
 drivers/usb/otg/isp1301_omap.c                     |    3 +-
 drivers/usb/otg/msm_otg.c                          |    3 +-
 drivers/usb/otg/mv_otg.c                           |    3 +-
 drivers/usb/otg/nop-usb-xceiv.c                    |    3 +-
 drivers/usb/otg/otg.c                              |  175 ++++++++++++++++----
 drivers/usb/otg/twl4030-usb.c                      |    3 +-
 drivers/usb/phy/mv_u3d_phy.c                       |    3 +-
 drivers/usb/phy/omap-usb2.c                        |   11 +-
 drivers/usb/phy/rcar-phy.c                         |    3 +-
 include/linux/usb/phy.h                            |   42 ++++-
 44 files changed, 245 insertions(+), 89 deletions(-)

-- 
1.7.9.5

^ permalink raw reply

* Re: [PATCH v3 0/2] memory-hotplug: introduce CONFIG_HAVE_BOOTMEM_INFO_NODE and revert register_page_bootmem_info_node() when platform not support
From: Michal Hocko @ 2013-01-16 14:15 UTC (permalink / raw)
  To: Lin Feng
  Cc: linux-ia64, aquini, heiko.carstens, tangchen, dhowells,
	paul.gortmaker, paulus, jbeulich, hpa, sparclinux, linux-s390,
	x86, isimatu.yasuaki, mingo, gerald.schaefer, fenghua.yu,
	jiang.liu, wency, mel, tglx, kamezawa.hiroyu, tony.luck, laijs,
	linux-mm, gregkh, linux-kernel, minchan, schwidefsky, linux390,
	akpm, linuxppc-dev, davem
In-Reply-To: <1358324059-9608-1-git-send-email-linfeng@cn.fujitsu.com>

On Wed 16-01-13 16:14:17, Lin Feng wrote:
[...]
> changeLog v2->v3:
> 1) patch 1/2:
> - Rename the patch title to conform it's content.
> - Update memory_hotplug.h and remove the misleading TODO pointed out by Michal.
> 2) patch 2/2:
> - New added, remove unimplemented functions suggested by Michal.

I think that both patches should be merged into one and put to Andrew's
queue as
memory-hotplug-implement-register_page_bootmem_info_section-of-sparse-vmemmap-fix.patch
rather than a separate patch.
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply

* Re: [PATCH v3 1/2] memory-hotplug: introduce CONFIG_HAVE_BOOTMEM_INFO_NODE and revert register_page_bootmem_info_node() when platform not support
From: Michal Hocko @ 2013-01-16 14:14 UTC (permalink / raw)
  To: Lin Feng
  Cc: linux-ia64, aquini, heiko.carstens, tangchen, dhowells,
	paul.gortmaker, paulus, jbeulich, hpa, sparclinux, linux-s390,
	x86, isimatu.yasuaki, mingo, gerald.schaefer, fenghua.yu,
	jiang.liu, wency, mel, tglx, kamezawa.hiroyu, tony.luck, laijs,
	linux-mm, gregkh, linux-kernel, minchan, schwidefsky, linux390,
	akpm, linuxppc-dev, davem
In-Reply-To: <1358324059-9608-2-git-send-email-linfeng@cn.fujitsu.com>

On Wed 16-01-13 16:14:18, Lin Feng wrote:
[...]
> diff --git a/mm/Kconfig b/mm/Kconfig
> index 278e3ab..f8c5799 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -162,10 +162,18 @@ config MOVABLE_NODE
>  	  Say Y here if you want to hotplug a whole node.
>  	  Say N here if you want kernel to use memory on all nodes evenly.
>  
> +#
> +# Only be set on architectures that have completely implemented memory hotplug
> +# feature. If you are not sure, don't touch it.
> +#
> +config HAVE_BOOTMEM_INFO_NODE
> +	def_bool n
> +
>  # eventually, we can have this option just 'select SPARSEMEM'
>  config MEMORY_HOTPLUG
>  	bool "Allow for memory hot-add"
>  	select MEMORY_ISOLATION
> +	select HAVE_BOOTMEM_INFO_NODE if X86_64
>  	depends on SPARSEMEM || X86_64_ACPI_NUMA
>  	depends on HOTPLUG && ARCH_ENABLE_MEMORY_HOTPLUG
>  	depends on (IA64 || X86 || PPC_BOOK3S_64 || SUPERH || S390)

I am still not sure I understand the relation to MEMORY_HOTREMOVE.
Is register_page_bootmem_info_node required/helpful even if
!CONFIG_MEMORY_HOTREMOVE?

Also, now that I am thinking about that more, maybe it would
be cleaner to put the select into arch/x86/Kconfig and do it
same as ARCH_ENABLE_MEMORY_{HOTPLUG,HOTREMOVE} (and name it
ARCH_HAVE_BOOTMEM_INFO_NODE).
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply

* SD Card over SPI, not working for MPC8313
From: R.Patil @ 2013-01-16 13:30 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1053 bytes --]

 Hello,

We are working on board based on Freescale MPC8313ERDB. We have ported linux 3.0.46 kernel on it. We have to use SD card over SPI. We are trying to use 'mmc_spi' driver for the same. We are able to detect SD card insertion by the interrupt (gpio interrupt is used to detect card insertion). But we are not able to initialise the card. Is the 'mmc_spi' support for MPC8313ERDB broken? 

If no, what could be the reason we are getting timeout error by function 'mmc_spi_response_get()'?&nbsp; 

If anybody could just give a hint to solve or debug the problem.&nbsp; 

Thanks and Regards,
Rahul Patil
Email Disclaimer:
  ---------------------------

This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and  privileged information. Computer viruses can be transmitted via email.The recipient should check this email and any  attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

[-- Attachment #2: Type: text/html, Size: 1246 bytes --]

^ permalink raw reply

* Re: [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
From: Jiri Olsa @ 2013-01-16 11:30 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Andi Kleen, Peter Zijlstra, robert.richter, Greg KH,
	Anton Blanchard, linux-kernel, Stephane Eranian, linuxppc-dev,
	Ingo Molnar, Paul Mackerras, Sukadev Bhattiprolu
In-Reply-To: <20130115185759.GG5826@ghostprotocols.net>

On Tue, Jan 15, 2013 at 03:57:59PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Jan 09, 2013 at 05:07:03PM -0800, Sukadev Bhattiprolu escreveu:
> > [PATCH 6/6][v3] perf: Document the ABI of perf sysfs entries
> > 
> > This patchset addes two new sets of files to sysfs:
> > 
> > 	- generic and POWER-specific perf events in /sys/devices/cpu/events/
> > 	- perf event config format in /sys/devices/cpu/format/event
> > 
> > Document the format of these files which would become part of the ABI.
> > 
> > Changelog[v3]:
> > 	[Greg KH] Include ABI documentation.
> 
> Jiri, can I have your ack on this one too?

hm, we already already 'format' definition but in testing section
(and we are missing 'events' definition there.. my bad)

anyway, after reading Documentation/ABI/README looks like we
should go for 'testing' section with this as well.. stable
seems scary at this point ;-)

jirka

> 
> Greg, all ok now?
> 
> - Arnaldo
>  
> > Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> > ---
> >  Documentation/ABI/stable/sysfs-devices-cpu-events |   54 +++++++++++++++++++++
> >  Documentation/ABI/stable/sysfs-devices-cpu-format |   27 ++++++++++
> >  2 files changed, 81 insertions(+), 0 deletions(-)
> >  create mode 100644 Documentation/ABI/stable/sysfs-devices-cpu-format
> > 
> > diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-events b/Documentation/ABI/stable/sysfs-devices-cpu-events
> > index e69de29..f37d542 100644
> > --- a/Documentation/ABI/stable/sysfs-devices-cpu-events
> > +++ b/Documentation/ABI/stable/sysfs-devices-cpu-events
> > @@ -0,0 +1,54 @@
> > +What:		/sys/devices/cpu/events/
> > +		/sys/devices/cpu/events/branch-misses
> > +		/sys/devices/cpu/events/cache-references
> > +		/sys/devices/cpu/events/cache-misses
> > +		/sys/devices/cpu/events/stalled-cycles-frontend
> > +		/sys/devices/cpu/events/branch-instructions
> > +		/sys/devices/cpu/events/stalled-cycles-backend
> > +		/sys/devices/cpu/events/instructions
> > +		/sys/devices/cpu/events/cpu-cycles
> > +
> > +Date:		2013/01/08
> > +
> > +Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
> > +
> > +Description:	Generic performance monitoring events
> > +
> > +		A collection of performance monitoring events that may be
> > +		supported by many/most CPUs. These events can be monitored
> > +		using the 'perf(1)' tool.
> > +
> > +		The contents of each file would look like:
> > +
> > +			event=0xNNNN
> > +
> > +		where 'N' is a hex digit.
> > +
> > +
> > +What: 		/sys/devices/cpu/events/PM_LD_MISS_L1
> > +		/sys/devices/cpu/events/PM_LD_REF_L1
> > +		/sys/devices/cpu/events/PM_CYC
> > +		/sys/devices/cpu/events/PM_BRU_FIN
> > +		/sys/devices/cpu/events/PM_GCT_NOSLOT_CYC
> > +		/sys/devices/cpu/events/PM_BRU_MPRED
> > +		/sys/devices/cpu/events/PM_INST_CMPL
> > +		/sys/devices/cpu/events/PM_CMPLU_STALL
> > +
> > +Date:		2013/01/08
> > +
> > +Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
> > +		Linux Powerpc mailing list <linuxppc-dev@ozlabs.org>
> > +
> > +Description:	POWER specific performance monitoring events
> > +
> > +		A collection of performance monitoring events that may be
> > +		supported by the POWER CPU. These events can be monitored
> > +		using the 'perf(1)' tool.
> > +
> > +		These events may not be supported by other CPUs.
> > +
> > +		The contents of each file would look like:
> > +
> > +			event=0xNNNN
> > +
> > +		where 'N' is a hex digit.
> > diff --git a/Documentation/ABI/stable/sysfs-devices-cpu-format b/Documentation/ABI/stable/sysfs-devices-cpu-format
> > new file mode 100644
> > index 0000000..b15cfb2
> > --- /dev/null
> > +++ b/Documentation/ABI/stable/sysfs-devices-cpu-format
> > @@ -0,0 +1,27 @@
> > +What:		/sys/devices/cpu/format/
> > +		/sys/devices/cpu/format/event
> > +
> > +Date:		2013/01/08
> > +
> > +Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
> > +
> > +Description:	Format of performance monitoring events
> > +
> > +		Each CPU/architecture may use different format to represent
> > +		the perf event.  The 'event' file describes the configuration
> > +		format of the performance monitoring event on the CPU/system.
> > +
> > +		The contents of each file would look like:
> > +
> > +			config:m-n
> > +
> > +		where m and n are the starting and ending bits that are
> > +		used to represent the event.
> > +
> > +		For example, on POWER,
> > +
> > +			$ cat /sys/devices/cpu/format/event
> > +			config:0-20
> > +
> > +		meaning that POWER uses the first 20-bits to represent a perf
> > +		event.
> > -- 
> > 1.7.1

^ permalink raw reply

* [PATCH 2/2] memory-hotplug: cleanup: removing the arch specific functions without any implementation
From: Lin Feng @ 2013-01-16  8:14 UTC (permalink / raw)
  To: akpm, mhocko, linux-mm, tglx, mingo, hpa, jbeulich, dhowells,
	wency, isimatu.yasuaki, paul.gortmaker, laijs, kamezawa.hiroyu,
	mel, minchan, aquini, jiang.liu, tony.luck, fenghua.yu, benh,
	paulus, schwidefsky, heiko.carstens, davem, michael,
	gerald.schaefer, gregkh
  Cc: linux-s390, linux-ia64, x86, linux-kernel, tangchen, linfeng,
	sparclinux, linux390, linuxppc-dev
In-Reply-To: <1358324059-9608-1-git-send-email-linfeng@cn.fujitsu.com>

From: Michal Hocko <mhocko@suse.cz>

After introducing CONFIG_HAVE_BOOTMEM_INFO_NODE Kconfig option, the related arch
specific functions become confusing, remove them.

Guys who want to implement memory-hotplug feature on such archs for this part
should look into register_page_bootmem_info_node() and flesh out from top to
end.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Lin Feng <linfeng@cn.fujitsu.com>
---
 arch/ia64/mm/discontig.c  |    5 -----
 arch/powerpc/mm/init_64.c |    5 -----
 arch/s390/mm/vmem.c       |    6 ------
 arch/sparc/mm/init_64.c   |    5 -----
 4 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 882a0fd..cb5e1ff 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -827,9 +827,4 @@ void vmemmap_free(struct page *memmap, unsigned long nr_pages)
 {
 }
 
-void register_page_bootmem_memmap(unsigned long section_nr,
-				  struct page *start_page, unsigned long size)
-{
-	/* TODO */
-}
 #endif
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 2969591..7e2246f 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -302,10 +302,5 @@ void vmemmap_free(struct page *memmap, unsigned long nr_pages)
 {
 }
 
-void register_page_bootmem_memmap(unsigned long section_nr,
-				  struct page *start_page, unsigned long size)
-{
-	/* TODO */
-}
 #endif /* CONFIG_SPARSEMEM_VMEMMAP */
 
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index 81e6ba3..fa09c2f 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -276,12 +276,6 @@ void vmemmap_free(struct page *memmap, unsigned long nr_pages)
 {
 }
 
-void register_page_bootmem_memmap(unsigned long section_nr,
-				  struct page *start_page, unsigned long size)
-{
-	/* TODO */
-}
-
 /*
  * Add memory segment to the segment list if it doesn't overlap with
  * an already present segment.
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index 5afe21a..76ac544 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -2236,11 +2236,6 @@ void vmemmap_free(struct page *memmap, unsigned long nr_pages)
 {
 }
 
-void register_page_bootmem_memmap(unsigned long section_nr,
-				  struct page *start_page, unsigned long size)
-{
-	/* TODO */
-}
 #endif /* CONFIG_SPARSEMEM_VMEMMAP */
 
 static void prot_init_common(unsigned long page_none,
-- 
1.7.1

^ permalink raw reply related

* [PATCH v3 1/2] memory-hotplug: introduce CONFIG_HAVE_BOOTMEM_INFO_NODE and revert register_page_bootmem_info_node() when platform not support
From: Lin Feng @ 2013-01-16  8:14 UTC (permalink / raw)
  To: akpm, mhocko, linux-mm, tglx, mingo, hpa, jbeulich, dhowells,
	wency, isimatu.yasuaki, paul.gortmaker, laijs, kamezawa.hiroyu,
	mel, minchan, aquini, jiang.liu, tony.luck, fenghua.yu, benh,
	paulus, schwidefsky, heiko.carstens, davem, michael,
	gerald.schaefer, gregkh
  Cc: linux-s390, linux-ia64, x86, linux-kernel, tangchen, linfeng,
	sparclinux, linux390, linuxppc-dev
In-Reply-To: <1358324059-9608-1-git-send-email-linfeng@cn.fujitsu.com>

It's implemented by adding a new Kconfig option named
CONFIG_HAVE_BOOTMEM_INFO_NODE, which will be automatically selected by
memory-hotplug feature fully supported archs(currently only on x86_64).

Reported-by: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Lin Feng <linfeng@cn.fujitsu.com>
---
ChangeLog v2->v3:
- Rename the patch title to conform it's content.
- Update memory_hotplug.h and remove the misleading TODO pointed out by Michal.

ChangeLog v1->v2:
- Add a Kconfig option named HAVE_BOOTMEM_INFO_NODE suggested by Michal, which
  will be automatically selected by supported archs(currently only on x86_64).
---
 arch/x86/mm/init_64.c          |    2 +-
 include/linux/memory_hotplug.h |    6 ++++++
 mm/Kconfig                     |    8 ++++++++
 mm/memory_hotplug.c            |    2 ++
 4 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 07d6966..b539015 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1317,7 +1317,7 @@ vmemmap_populate(struct page *start_page, unsigned long size, int node)
 	return 0;
 }
 
-#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
+#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HAVE_BOOTMEM_INFO_NODE)
 void register_page_bootmem_memmap(unsigned long section_nr,
 				  struct page *start_page, unsigned long size)
 {
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index f60e728..69903cc 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -174,7 +174,13 @@ static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat)
 #endif /* CONFIG_NUMA */
 #endif /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */
 
+#ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
 extern void register_page_bootmem_info_node(struct pglist_data *pgdat);
+#else
+static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
+{
+}
+#endif
 extern void put_page_bootmem(struct page *page);
 extern void get_page_bootmem(unsigned long ingo, struct page *page,
 			     unsigned long type);
diff --git a/mm/Kconfig b/mm/Kconfig
index 278e3ab..f8c5799 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -162,10 +162,18 @@ config MOVABLE_NODE
 	  Say Y here if you want to hotplug a whole node.
 	  Say N here if you want kernel to use memory on all nodes evenly.
 
+#
+# Only be set on architectures that have completely implemented memory hotplug
+# feature. If you are not sure, don't touch it.
+#
+config HAVE_BOOTMEM_INFO_NODE
+	def_bool n
+
 # eventually, we can have this option just 'select SPARSEMEM'
 config MEMORY_HOTPLUG
 	bool "Allow for memory hot-add"
 	select MEMORY_ISOLATION
+	select HAVE_BOOTMEM_INFO_NODE if X86_64
 	depends on SPARSEMEM || X86_64_ACPI_NUMA
 	depends on HOTPLUG && ARCH_ENABLE_MEMORY_HOTPLUG
 	depends on (IA64 || X86 || PPC_BOOK3S_64 || SUPERH || S390)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 8aa2b56..daf111f 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -189,6 +189,7 @@ static void register_page_bootmem_info_section(unsigned long start_pfn)
 }
 #endif
 
+#ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
 void register_page_bootmem_info_node(struct pglist_data *pgdat)
 {
 	unsigned long i, pfn, end_pfn, nr_pages;
@@ -230,6 +231,7 @@ void register_page_bootmem_info_node(struct pglist_data *pgdat)
 			register_page_bootmem_info_section(pfn);
 	}
 }
+#endif
 
 static void grow_zone_span(struct zone *zone, unsigned long start_pfn,
 			   unsigned long end_pfn)
-- 
1.7.1

^ permalink raw reply related

* [PATCH v3 0/2] memory-hotplug: introduce CONFIG_HAVE_BOOTMEM_INFO_NODE and revert register_page_bootmem_info_node() when platform not support
From: Lin Feng @ 2013-01-16  8:14 UTC (permalink / raw)
  To: akpm, mhocko, linux-mm, tglx, mingo, hpa, jbeulich, dhowells,
	wency, isimatu.yasuaki, paul.gortmaker, laijs, kamezawa.hiroyu,
	mel, minchan, aquini, jiang.liu, tony.luck, fenghua.yu, benh,
	paulus, schwidefsky, heiko.carstens, davem, michael,
	gerald.schaefer, gregkh
  Cc: linux-s390, linux-ia64, x86, linux-kernel, tangchen, linfeng,
	sparclinux, linux390, linuxppc-dev

Memory-hotplug codes for x86_64 have been implemented by patchset:
https://lkml.org/lkml/2013/1/9/124
While other platforms haven't been completely implemented yet.

If we enable both CONFIG_MEMORY_HOTPLUG_SPARSE and CONFIG_SPARSEMEM_VMEMMAP,
register_page_bootmem_info_node() may be buggy, which is a hotplug generic
function but falling back to call platform related function
register_page_bootmem_memmap().

Other platforms such as powerpc it's not implemented, so on such platforms,
revert them to empty as they were before.

It's implemented by adding a new Kconfig option named
CONFIG_HAVE_BOOTMEM_INFO_NODE, which will be automatically selected by
memory-hotplug supported archs(currently only on x86_64).

changeLog v2->v3:
1) patch 1/2:
- Rename the patch title to conform it's content.
- Update memory_hotplug.h and remove the misleading TODO pointed out by Michal.
2) patch 2/2:
- New added, remove unimplemented functions suggested by Michal.

ChangeLog v1->v2:
1) patch 1/2:
- Add a Kconfig option named HAVE_BOOTMEM_INFO_NODE suggested by Michal, which
  will be automatically selected by supported archs(currently only on x86_64).

Lin Feng (1):
  memory-hotplug: revert register_page_bootmem_info_node() to empty
    when platform related code is not implemented

Michal Hocko (1):
  memory-hotplug: cleanup: removing the arch specific functions without
    any implementation

 arch/ia64/mm/discontig.c       |    5 -----
 arch/powerpc/mm/init_64.c      |    5 -----
 arch/s390/mm/vmem.c            |    6 ------
 arch/sparc/mm/init_64.c        |    5 -----
 arch/x86/mm/init_64.c          |    2 +-
 include/linux/memory_hotplug.h |    6 ++++++
 mm/Kconfig                     |    8 ++++++++
 mm/memory_hotplug.c            |    2 ++
 8 files changed, 17 insertions(+), 22 deletions(-)

^ permalink raw reply

* [v1][PATCH 1/1] ppc64: max next_tb to prevent from replaying timer interrupt
From: Tiejun Chen @ 2013-01-16  3:01 UTC (permalink / raw)
  To: benh, galak; +Cc: linuxppc-dev, linux-kernel

With lazy interrupt, we always call __check_irq_replaysome with
decrementers_next_tb to check if we need to replay timer interrupt.
So in hotplug case we also need to set decrementers_next_tb as MAX
to make sure __check_irq_replay don't replay timer interrupt
when return as we expect, otherwise we'll trap here infinitely.

Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
---
v1:

* In hotplug case we max decrementers_next_tb to prevent from
replaying timer interrupt for any offline CPU.

 arch/powerpc/kernel/time.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 6f6b1cc..127361e 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -494,10 +494,15 @@ void timer_interrupt(struct pt_regs * regs)
 	set_dec(DECREMENTER_MAX);
 
 	/* Some implementations of hotplug will get timer interrupts while
-	 * offline, just ignore these
+	 * offline, just ignore these and we also need to set
+	 * decrementers_next_tb as MAX to make sure __check_irq_replay
+	 * don't replay timer interrupt when return, otherwise we'll trap
+	 * here infinitely :(
 	 */
-	if (!cpu_online(smp_processor_id()))
+	if (!cpu_online(smp_processor_id())) {
+		*next_tb = ~(u64)0;
 		return;
+	}
 
 	/* Conditionally hard-enable interrupts now that the DEC has been
 	 * bumped to its maximum value
-- 
1.7.9.5

^ permalink raw reply related

* Re: [RFC][v0][PATCH 1/1] ppc64: ignore interrupts while offline
From: tiejun.chen @ 2013-01-16  3:00 UTC (permalink / raw)
  To: benh, galak; +Cc: linuxppc-dev, linux-kernel
In-Reply-To: <1358245860-6546-1-git-send-email-tiejun.chen@windriver.com>

Please ignore this to check next version.

Tiejun

On 01/15/2013 06:31 PM, Tiejun Chen wrote:
> With lazy interrupt, some implementations of hotplug will
> get some interrupts even while offline, just ignore these.
>
> Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
> ---
>   arch/powerpc/kernel/irq.c |    6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
> index 4f97fe3..dbca574 100644
> --- a/arch/powerpc/kernel/irq.c
> +++ b/arch/powerpc/kernel/irq.c
> @@ -144,6 +144,12 @@ notrace unsigned int __check_irq_replay(void)
>   	 */
>   	unsigned char happened = local_paca->irq_happened;
>
> +	/* Some implementations of hotplug will get some interrupts while
> +	 * offline, just ignore these.
> +	 */
> +	if (cpu_is_offline(smp_processor_id()))
> +		return 0;
> +
>   	/* Clear bit 0 which we wouldn't clear otherwise */
>   	local_paca->irq_happened &= ~PACA_IRQ_HARD_DIS;
>
>

^ permalink raw reply

* Re: [BUG Fix Patch 1/6] Bug fix: Hold spinlock across find|remove /sys/firmware/memmap/X operation.
From: Tang Chen @ 2013-01-16  2:12 UTC (permalink / raw)
  To: Julian Calaby
  Cc: linux-ia64, linux-sh, linux-mm, paulus, hpa, sparclinux, cl,
	linux-s390, x86, linux-acpi, isimatu.yasuaki, linfeng, mgorman,
	kosaki.motohiro, rientjes, len.brown, jiang.liu, wency, cmetcalf,
	glommer, wujianguo, yinghai, laijs, linux-kernel, minchan.kim,
	akpm, linuxppc-dev
In-Reply-To: <CAGRGNgWCdvWhp=9+PDRbC9bK100BdBv9kpcsqoM-J6ipq22Szw@mail.gmail.com>

On 01/16/2013 06:26 AM, Julian Calaby wrote:
> Hi Tang,
>
> One minor point.
>
>>
>>   /*
>> - * Search memmap entry
>> + * firmware_map_find_entry: Search memmap entry.
>> + * @start: Start of the memory range.
>> + * @end:   End of the memory range (exclusive).
>> + * @type:  Type of the memory range.
>> + *
>> + * This function is to find the memmap entey of a given memory range.
>> + * The caller must hold map_entries_lock, and must not release the lock
>> + * until the processing of the returned entry has completed.
>> + *
>> + * Return pointer to the entry to be found on success, or NULL on failure.
>
> Why not make this completely kernel-doc compliant as you're already
> re-writing the comment?

Hi Julian,

Thank you for reminding me this. I think I may have some more problems
like this. I'll post a patch to fix as many of them as I can. :)

Thanks.

^ permalink raw reply

* Re: [PATCH v5 1/3] usb: fsl-mxc-udc: replace cpu_is_xxx() with platform_device_id
From: Peter Chen @ 2013-01-16  1:48 UTC (permalink / raw)
  To: Shawn Guo
  Cc: r58472, gregkh, linux-usb, balbi, kernel, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <20130115140344.GB6574@S2101-09.ap.freescale.net>

On Tue, Jan 15, 2013 at 10:03:46PM +0800, Shawn Guo wrote:
> On Tue, Jan 15, 2013 at 10:29:33AM +0800, Peter Chen wrote:
> > As mach/hardware.h is deleted, we need to use platform_device_id to
> > differentiate SoCs. Besides, one cpu_is_mx35 is useless as it has
> > already used pdata to differentiate runtime
> > 
> > Meanwhile we update the platform code accordingly.
> > 
> > Signed-off-by: Peter Chen <peter.chen@freescale.com>
> > ---
> >  arch/arm/mach-imx/devices/devices-common.h        |    1 +
> >  arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c |   15 ++++---
> >  drivers/usb/gadget/fsl_mxc_udc.c                  |   24 +++++-------
> >  drivers/usb/gadget/fsl_udc_core.c                 |   42 +++++++++++++--------
> >  4 files changed, 45 insertions(+), 37 deletions(-)
> 
> Since we are splitting the original patch anyway, it's a bit strange
> to me that you are mixing arch/arm/mach-imx and drivers/usb/gadget
> in this patch.  I'm fine with it, since I assume all the patches to
> go via USB tree anyway.
> 
> > 
> > diff --git a/arch/arm/mach-imx/devices/devices-common.h b/arch/arm/mach-imx/devices/devices-common.h
> > index 6277baf..9bd5777 100644
> > --- a/arch/arm/mach-imx/devices/devices-common.h
> > +++ b/arch/arm/mach-imx/devices/devices-common.h
> > @@ -63,6 +63,7 @@ struct platform_device *__init imx_add_flexcan(
> >  
> >  #include <linux/fsl_devices.h>
> >  struct imx_fsl_usb2_udc_data {
> > +	const char *devid;
> >  	resource_size_t iobase;
> >  	resource_size_t irq;
> >  };
> > diff --git a/arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c b/arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c
> > index 37e4439..fb527c7 100644
> > --- a/arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c
> > +++ b/arch/arm/mach-imx/devices/platform-fsl-usb2-udc.c
> > @@ -11,35 +11,36 @@
> >  #include "../hardware.h"
> >  #include "devices-common.h"
> >  
> > -#define imx_fsl_usb2_udc_data_entry_single(soc)				\
> > +#define imx_fsl_usb2_udc_data_entry_single(soc, _devid)			\
> >  	{								\
> > +		.devid = _devid,					\
> >  		.iobase = soc ## _USB_OTG_BASE_ADDR,			\
> >  		.irq = soc ## _INT_USB_OTG,				\
> >  	}
> >  
> >  #ifdef CONFIG_SOC_IMX25
> >  const struct imx_fsl_usb2_udc_data imx25_fsl_usb2_udc_data __initconst =
> > -	imx_fsl_usb2_udc_data_entry_single(MX25);
> > +	imx_fsl_usb2_udc_data_entry_single(MX25, "imx-udc-mx25");
> >  #endif /* ifdef CONFIG_SOC_IMX25 */
> >  
> >  #ifdef CONFIG_SOC_IMX27
> >  const struct imx_fsl_usb2_udc_data imx27_fsl_usb2_udc_data __initconst =
> > -	imx_fsl_usb2_udc_data_entry_single(MX27);
> > +	imx_fsl_usb2_udc_data_entry_single(MX27, "imx-udc-mx27");
> >  #endif /* ifdef CONFIG_SOC_IMX27 */
> >  
> >  #ifdef CONFIG_SOC_IMX31
> >  const struct imx_fsl_usb2_udc_data imx31_fsl_usb2_udc_data __initconst =
> > -	imx_fsl_usb2_udc_data_entry_single(MX31);
> > +	imx_fsl_usb2_udc_data_entry_single(MX31, "imx-udc-mx31");
> >  #endif /* ifdef CONFIG_SOC_IMX31 */
> >  
> >  #ifdef CONFIG_SOC_IMX35
> >  const struct imx_fsl_usb2_udc_data imx35_fsl_usb2_udc_data __initconst =
> > -	imx_fsl_usb2_udc_data_entry_single(MX35);
> > +	imx_fsl_usb2_udc_data_entry_single(MX35, "imx-udc-mx35");
> >  #endif /* ifdef CONFIG_SOC_IMX35 */
> >  
> >  #ifdef CONFIG_SOC_IMX51
> >  const struct imx_fsl_usb2_udc_data imx51_fsl_usb2_udc_data __initconst =
> > -	imx_fsl_usb2_udc_data_entry_single(MX51);
> > +	imx_fsl_usb2_udc_data_entry_single(MX51, "imx-udc-mx51");
> >  #endif
> >  
> >  struct platform_device *__init imx_add_fsl_usb2_udc(
> > @@ -57,7 +58,7 @@ struct platform_device *__init imx_add_fsl_usb2_udc(
> >  			.flags = IORESOURCE_IRQ,
> >  		},
> >  	};
> > -	return imx_add_platform_device_dmamask("fsl-usb2-udc", -1,
> > +	return imx_add_platform_device_dmamask(data->devid, -1,
> >  			res, ARRAY_SIZE(res),
> >  			pdata, sizeof(*pdata), DMA_BIT_MASK(32));
> >  }
> 
> <snip>
> 
> > +static const struct platform_device_id fsl_udc_devtype[] = {
> > +	{
> > +		.name = "imx-udc-mx25",
> > +	}, {
> > +		.name = "imx-udc-mx27",
> > +	}, {
> > +		.name = "imx-udc-mx31",
> > +	}, {
> > +		.name = "imx-udc-mx35",
> > +	}, {
> > +		.name = "imx-udc-mx51",
> > +	}
> > +};
> 
> From what I understand balbi's comment, he dislikes this full list of
> device id.  Instead, he prefers to something like below.
> 
> static const struct platform_device_id fsl_udc_devtype[] = {
> 	{
> 		.name = "imx-udc-mx27",
> 	}, {
> 		.name = "imx-udc-mx51",
> 	}
> };
> 
> It basically tells that we are handling two type of devices here, one
> is imx-udc-mx27 type and the other is imx-udc-mx51 type, with mx25/31/35
> completely compatible with mx27 type.  We choose mx27 instead of mx25
> to define the type because mx27 Si came out earlier than mx25.  That
> said, we generally choose the earlies SoC name to define a particular
> version of IP block, since hardware version is mostly unavailable or
> unreliable.
> 
> But that also means in platform code which create the platform_device,
> you will need to use name "imx-udc-mx27" for even mx25/31/35.
> 
> 	imx_fsl_usb2_udc_data_entry_single(MX25, "imx-udc-mx27");
> 	imx_fsl_usb2_udc_data_entry_single(MX31, "imx-udc-mx27");
> 	imx_fsl_usb2_udc_data_entry_single(MX35, "imx-udc-mx27");
> 
> Considering this is a piece of code we will not use for any new
> hardware, I'm fine with either way.
> 
> So, balbi, it's all your call to accept the series as it is or ask for
> another iteration.
Thanks Shawn. Let's see Felipe's comment, nevertheless, I will send v6 patch
due to a compile error at mx25

> 
> Shawn

-- 

Best Regards,
Peter Chen

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox