RE: [PATCH V4 2/2] powerpc/85xx: Add PCIe controller support for bsc9132qds

2015-11-16 Thread Hou Zhiqiang
Hi,

Any response, please comment.

> -Original Message-
> From: Zhiqiang Hou [mailto:zhiqiang@freescale.com]
> Sent: 2015年11月5日 11:16
> To: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421;
> ga...@kernel.crashing.org; b...@kernel.crashing.org; pau...@samba.org;
> m...@ellerman.id.au; devicet...@vger.kernel.org; robh...@kernel.org;
> pawel.m...@arm.com; mark.rutl...@arm.com; ijc+devicet...@hellion.org.uk;
> Rai Harninder-B01044
> Cc: Lian Minghuan-B31939; Hu Mingkai-B21284; Hou Zhiqiang-B48286
> Subject: [PATCH V4 2/2] powerpc/85xx: Add PCIe controller support for
> bsc9132qds
> 
> From: Harninder Rai <harninder@freescale.com>
> 
> 1. Use machine_arch_initcall to hook mpc85xx_common_publish_devices This
> can ensure before pcibios_init() is called, pci controllers have been
> probed and added to the hose_list.
> 2. Add a workaround for errata A-005434
> For the BSC9132, PEX_PEXIWARn[TRGT] for all windows defaults to 0xF,
> which is mapped to CCSRBAR. However, for other products, 0xF is mapped to
> the local memory. Therefore, for the BSC9132, any default PCI Express
> access to the local memory (DDR) will now access the CCSRBAR. This patch
> changes the mapping of targets of inbound windows PEX_PEXIWARn[TRGT] to
> the Local address space – 0x0 (from 0xF).
> 
> Signed-off-by: Harninder Rai <harninder@freescale.com>
> Signed-off-by: Minghuan Lian <minghuan.l...@freescale.com>
> Signed-off-by: Hou Zhiqiang <b48...@freescale.com>
> ---
> V4: V3:
>  - Remove gerrit stuff.
> 
>  arch/powerpc/platforms/85xx/bsc913x_qds.c |  8 +++-
>  arch/powerpc/sysdev/fsl_pci.c | 13 +
>  2 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/85xx/bsc913x_qds.c
> b/arch/powerpc/platforms/85xx/bsc913x_qds.c
> index f0927e5..dcfafd6 100644
> --- a/arch/powerpc/platforms/85xx/bsc913x_qds.c
> +++ b/arch/powerpc/platforms/85xx/bsc913x_qds.c
> @@ -17,6 +17,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
> 
>  #include "mpc85xx.h"
> @@ -46,10 +47,12 @@ static void __init bsc913x_qds_setup_arch(void)
>   mpc85xx_smp_init();
>  #endif
> 
> + fsl_pci_assign_primary();
> +
>   pr_info("bsc913x board from Freescale Semiconductor\n");  }
> 
> -machine_device_initcall(bsc9132_qds, mpc85xx_common_publish_devices);
> +machine_arch_initcall(bsc9132_qds, mpc85xx_common_publish_devices);
> 
>  /*
>   * Called very early, device-tree isn't unflattened @@ -67,6 +70,9 @@
> define_machine(bsc9132_qds) {
>   .probe  = bsc9132_qds_probe,
>   .setup_arch = bsc913x_qds_setup_arch,
>   .init_IRQ   = bsc913x_qds_pic_init,
> +#ifdef CONFIG_PCI
> + .pcibios_fixup_bus  = fsl_pcibios_fixup_bus,
> +#endif
>   .get_irq= mpic_get_irq,
>   .restart= fsl_rstcr_restart,
>   .calibrate_decr = generic_calibrate_decr,
> diff --git a/arch/powerpc/sysdev/fsl_pci.c
> b/arch/powerpc/sysdev/fsl_pci.c index ebc1f412..b8607f6 100644
> --- a/arch/powerpc/sysdev/fsl_pci.c
> +++ b/arch/powerpc/sysdev/fsl_pci.c
> @@ -193,6 +193,19 @@ static void setup_pci_atmu(struct pci_controller
> *hose)
>   const u64 *reg;
>   int len;
> 
> + if (of_device_is_compatible(hose->dn, "fsl,bsc9132-pcie")) {
> + /*
> +  * BSC9132 Rev1.0 has an issue where all the PEX inbound
> +  * windows have implemented the default target value as 0xf
> +  * for CCSR space.In all Freescale legacy devices the target
> +  * of 0xf is reserved for local memory space. 9132 Rev1.0
> +  * now has local mempry space mapped to target 0x0 instead of
> +  * 0xf. Hence adding a workaround to remove the target 0xf
> +  * defined for memory space from Inbound window attributes.
> +  */
> + piwar &= ~PIWAR_TGI_LOCAL;
> + }
> +
>   if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
>   if (in_be32(>block_rev1) >= PCIE_IP_REV_2_2) {
>   win_idx = 2;
> --
> 2.1.0.27.g96db324

Thanks,
Zhiqiang
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [PATCH V3 1/2] powerpc/fsl: Add PCI node in device tree of bsc9132qds

2015-11-04 Thread Hou Zhiqiang


> -Original Message-
> From: Wood Scott-B07421
> Sent: 2015年11月5日 11:09
> To: Zhiqiang Hou
> Cc: linuxppc-dev@lists.ozlabs.org; ga...@kernel.crashing.org;
> b...@kernel.crashing.org; pau...@samba.org; m...@ellerman.id.au;
> devicet...@vger.kernel.org; robh...@kernel.org; pawel.m...@arm.com;
> mark.rutl...@arm.com; ijc+devicet...@hellion.org.uk; Rai Harninder-B01044;
> Lian Minghuan-B31939; Hu Mingkai-B21284; Hou Zhiqiang-B48286
> Subject: Re: [PATCH V3 1/2] powerpc/fsl: Add PCI node in device tree of
> bsc9132qds
> 
> On Thu, 2015-11-05 at 10:52 +0800, Zhiqiang Hou wrote:
> > From: Harninder Rai <harninder@freescale.com>
> >
> > Signed-off-by: Harninder Rai <harninder@freescale.com>
> > Signed-off-by: Minghuan Lian <minghuan.l...@freescale.com>
> > Reviewed-by: Zang Tiefei-R61911 <tie-fei.z...@freescale.com>
> > Reviewed-by: Kushwaha Prabhakar-B32579 <prabha...@freescale.com>
> > Reviewed-by: Fleming Andrew-AFLEMING <aflem...@freescale.com>
> > Tested-by: Fleming Andrew-AFLEMING <aflem...@freescale.com>
> > Signed-off-by: Hou Zhiqiang <b48...@freescale.com>
> > ---
> > V3:
> >  - Remove gerrit stuff.
> 
> No, you didn't remove all of the Gerrit stuff.  Get rid of all the
> Reviewed- by and Tested-by since they are not relevant to this context.
> Hitting "+1"
> in Gerrit to allow a patch to go into the SDK tree a few years ago is not
> the same as reviewing it for inclusion in mainline Linux today.
 
Ok, thanks.

Zhiqiang
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [V2,1/2] powerpc/fsl: Add PCI node in device tree of bsc9132qds

2015-10-18 Thread Hou Zhiqiang


> -Original Message-
> From: Wood Scott-B07421
> Sent: 2015年10月17日 9:34
> To: Hou Zhiqiang-B48286
> Cc: linuxppc-dev@lists.ozlabs.org; ga...@kernel.crashing.org;
> b...@kernel.crashing.org; pau...@samba.org; m...@ellerman.id.au;
> devicet...@vger.kernel.org; robh...@kernel.org; pawel.m...@arm.com;
> mark.rutl...@arm.com; ijc+devicet...@hellion.org.uk; Rai Harninder-B01044;
> Lian Minghuan-B31939; Hu Mingkai-B21284
> Subject: Re: [V2,1/2] powerpc/fsl: Add PCI node in device tree of
> bsc9132qds
> 
> On Fri, Oct 16, 2015 at 05:01:10PM +0800, Zhiqiang Hou wrote:
> > From: Harninder Rai <harninder@freescale.com>
> >
> > Signed-off-by: Harninder Rai <harninder@freescale.com>
> > Signed-off-by: Minghuan Lian <minghuan.l...@freescale.com>
> > Change-Id: I4355add4a92d1fcf514843aea5ecadd2e2517969
> > Reviewed-on: http://git.am.freescale.net:8181/2454
> > Reviewed-by: Zang Tiefei-R61911 <tie-fei.z...@freescale.com>
> > Reviewed-by: Kushwaha Prabhakar-B32579 <prabha...@freescale.com>
> > Reviewed-by: Fleming Andrew-AFLEMING <aflem...@freescale.com>
> > Tested-by: Fleming Andrew-AFLEMING <aflem...@freescale.com>
> 
> Again:
> 
> Get rid of the gerrit stuff.  And where is your signoff?

Ok.

Thanks,
Zhiqiang
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [v3,1/5] powerpc/fsl: Move fsl_guts.h out of arch/powerpc

2015-10-15 Thread Hou Zhiqiang

> -Original Message-
> From patchwork Sun Sep 20 04:29:53 2015   
>  
> Content-Type: text/plain; charset="utf-8" 
>  
> MIME-Version: 1.0 
>  
> Content-Transfer-Encoding: 7bit   
>  
> Subject: [v3,1/5] powerpc/fsl: Move fsl_guts.h out of arch/powerpc
>  
> From: Scott Wood 
>  
> X-Patchwork-Id: 7225421   
>  
> Message-Id: <1442723397-26329-2-git-send-email-scottw...@freescale.com>   
>  
> To: Michael Turquette , Stephen Boyd 
>  
>   , "Rafael J. Wysocki" ,   
>   
>   Viresh Kumar
>  
>   , Russell King 
>  
> Cc: linux...@vger.kernel.org, Tang Yuantian ,
>  
>   Scott Wood , linuxppc-dev@lists.ozlabs.org,
>  
>   linux-...@vger.kernel.org, linux-arm-ker...@lists.infradead.org 
>  
> Date: Sat, 19 Sep 2015 23:29:53 -0500 
>  
>   
>  
> Freescale's Layerscape ARM chips use the same structure.  
>  
>   
>  
> Signed-off-by: Scott Wood    
>  
>   
>  
> ---   
>  
> v3: was patch 2/5 
>  
>   
>  
>  arch/powerpc/include/asm/fsl_guts.h| 192 
> -
>  arch/powerpc/platforms/85xx/mpc85xx_mds.c  |   2 +-  
>  
>  arch/powerpc/platforms/85xx/mpc85xx_rdb.c  |   2 +-  
>  
>  arch/powerpc/platforms/85xx/p1022_ds.c |   2 +-  
>  
>  arch/powerpc/platforms/85xx/p1022_rdk.c|   2 +-  
>  
>  arch/powerpc/platforms/85xx/smp.c  |   2 +-  
>  
>  arch/powerpc/platforms/85xx/twr_p102x.c|   2 +-  
>  
>  arch/powerpc/platforms/86xx/mpc8610_hpcd.c |   2 +-  
>  
>  drivers/iommu/fsl_pamu.c   |   2 +-  
>  
>  include/linux/fsl/guts.h   | 192 
> +
>  sound/soc/fsl/mpc8610_hpcd.c   |   2 +-  
>  
>  sound/soc/fsl/p1022_ds.c   |   2 +-  
>  
>  sound/soc/fsl/p1022_rdk.c  |   2 +-  
>  
>  13 files changed, 203 insertions(+), 203 deletions(-)
>  
>  delete mode 100644 arch/powerpc/include/asm/fsl_guts.h   
>  
>  create mode 100644 include/linux/fsl/guts.h  
>  

LS1043A clock driver depends on this patchset, and tested on LS1043ARDB board.

Thanks,
Zhiqiang
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [PATCH 1/2] powerpc/fsl: Add PCI node in device tree of bsc9132qds

2015-10-14 Thread Hou Zhiqiang


> -Original Message-
> From: Wood Scott-B07421
> Sent: 2015年10月15日 4:36
> To: Hou Zhiqiang-B48286
> Cc: linuxppc-dev@lists.ozlabs.org; ga...@kernel.crashing.org;
> b...@kernel.crashing.org; pau...@samba.org; m...@ellerman.id.au;
> devicet...@vger.kernel.org; robh...@kernel.org; pawel.m...@arm.com;
> mark.rutl...@arm.com; ijc+devicet...@hellion.org.uk; Rai Harninder-B01044;
> Lian Minghuan-B31939; Hu Mingkai-B21284
> Subject: Re: [PATCH 1/2] powerpc/fsl: Add PCI node in device tree of
> bsc9132qds
> 
> On Tue, 2015-10-13 at 19:29 +0800, Zhiqiang Hou wrote:
> > From: Harninder Rai <harninder@freescale.com>
> >
> > Signed-off-by: Harninder Rai <harninder@freescale.com>
> > Signed-off-by: Minghuan Lian <minghuan.l...@freescale.com>
> > Change-Id: I4355add4a92d1fcf514843aea5ecadd2e2517969
> > Reviewed-on: http://git.am.freescale.net:8181/2454
> > Reviewed-by: Zang Tiefei-R61911 <tie-fei.z...@freescale.com>
> > Reviewed-by: Kushwaha Prabhakar-B32579 <prabha...@freescale.com>
> > Reviewed-by: Fleming Andrew-AFLEMING <aflem...@freescale.com>
> > Tested-by: Fleming Andrew-AFLEMING <aflem...@freescale.com>
> 
> Get rid of the gerrit stuff.  And where is your signoff?
> 
> > diff --git a/arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi
> > b/arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi
> > index c723071..78c8f1c 100644
> > --- a/arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi
> > +++ b/arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi
> > @@ -40,6 +40,35 @@
> >   interrupts = <16 2 0 0 20 2 0 0>;  };
> >
> > +/* controller at 0xa000 */
> > + {
> > + compatible = "fsl,bsc9132-pcie", "fsl,qoriq-pcie-v2.2";
> > + device_type = "pci";
> > + #size-cells = <2>;
> > + #address-cells = <3>;
> > + bus-range = <0 255>;
> > + clock-frequency = <>;
> > + interrupts = <16 2 0 0>;
> 
> This clock-frequency is not correct for PCIe.  Just remove it.
> 

Ok, thanks for your correction.
 

Thanks,
Zhiqiang

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [PATCH V2] powerpc/85xx: Remove unused pci fixup hooks on c293pcie

2015-08-18 Thread Hou Zhiqiang
Hi Scott,

Removed both pcibios_fixup_phb and pcibios_fixup_bus.
Could you please help to apply it?

 -Original Message-
 From: Zhiqiang Hou [mailto:b48...@freescale.com]
 Sent: 2015年8月10日 17:40
 To: ga...@kernel.crashing.org; linuxppc-dev@lists.ozlabs.org; Wood Scott-
 B07421
 Cc: Hu Mingkai-B21284; Wang Dongsheng-B40534; Hou Zhiqiang-B48286
 Subject: [PATCH V2] powerpc/85xx: Remove unused pci fixup hooks on
 c293pcie
 
 From: Hou Zhiqiang b48...@freescale.com
 
 The c293pcie board is an endpoint device and it doesn't need PM, so
 remove hooks pcibios_fixup_phb and pcibios_fixup_bus.
 
 Signed-off-by: Hou Zhiqiang b48...@freescale.com
 ---
 Test on c293pcie board:
 V2:
 Rename the title of this patch.
 Remove pcibios_fixup_bus that isn't used in EP.
 
  arch/powerpc/platforms/85xx/c293pcie.c | 4 
  1 file changed, 4 deletions(-)
 
 diff --git a/arch/powerpc/platforms/85xx/c293pcie.c
 b/arch/powerpc/platforms/85xx/c293pcie.c
 index 84476b6..61bc851 100644
 --- a/arch/powerpc/platforms/85xx/c293pcie.c
 +++ b/arch/powerpc/platforms/85xx/c293pcie.c
 @@ -66,10 +66,6 @@ define_machine(c293_pcie) {
   .probe  = c293_pcie_probe,
   .setup_arch = c293_pcie_setup_arch,
   .init_IRQ   = c293_pcie_pic_init,
 -#ifdef CONFIG_PCI
 - .pcibios_fixup_bus  = fsl_pcibios_fixup_bus,
 - .pcibios_fixup_phb  = fsl_pcibios_fixup_phb,
 -#endif
   .get_irq= mpic_get_irq,
   .restart= fsl_rstcr_restart,
   .calibrate_decr = generic_calibrate_decr,
 --
 2.1.0.27.g96db324

Thanks,
Zhiqiang

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [PATCH] c293/pci: remove hook pcibios_fixup_phb

2015-08-10 Thread Hou Zhiqiang


 -Original Message-
 From: Wood Scott-B07421
 Sent: 2015年8月1日 1:24
 To: Hou Zhiqiang-B48286
 Cc: ga...@kernel.crashing.org; linuxppc-dev@lists.ozlabs.org; Hu Mingkai-
 B21284; Wang Dongsheng-B40534
 Subject: Re: [PATCH] c293/pci: remove hook pcibios_fixup_phb
 
 On Fri, 2015-07-31 at 05:59 -0500, Hou Zhiqiang-B48286 wrote:
  Hi Dongsheng and Scott,
 
  Do you have any comment?
 
   -Original Message-
   From: Zhiqiang Hou [mailto:b48...@freescale.com]
   Sent: 2015年7月21日 18:10
   To: ga...@kernel.crashing.org; linuxppc-dev@lists.ozlabs.org
   Cc: Hu Mingkai-B21284; Wang Dongsheng-B40534; Hou Zhiqiang-B48286
   Subject: [PATCH] c293/pci: remove hook pcibios_fixup_phb
  
   From: Hou Zhiqiang b48...@freescale.com
  
   The c293pcie board is an endpoint device, and it does't need PM.
  
   Signed-off-by: Hou Zhiqiang b48...@freescale.com
   ---
arch/powerpc/platforms/85xx/c293pcie.c | 1 -
1 file changed, 1 deletion(-)
  
   diff --git a/arch/powerpc/platforms/85xx/c293pcie.c
   b/arch/powerpc/platforms/85xx/c293pcie.c
   index 84476b6..213d5b8 100644
   --- a/arch/powerpc/platforms/85xx/c293pcie.c
   +++ b/arch/powerpc/platforms/85xx/c293pcie.c
   @@ -68,7 +68,6 @@ define_machine(c293_pcie) {
   .init_IRQ   = c293_pcie_pic_init,
#ifdef CONFIG_PCI
   .pcibios_fixup_bus  = fsl_pcibios_fixup_bus,
   -   .pcibios_fixup_phb  = fsl_pcibios_fixup_phb,
#endif
   .get_irq= mpic_get_irq,
   .restart= fsl_rstcr_restart,
 
 If this is an endpoint why do you need pcibios_fixup_bus?
 

Thanks and yes, it isn't used in endpoint mode.
Removed it in patch version 2.

 -Scott

Thanks,
Zhiqiang
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [PATCH] c293/pci: remove hook pcibios_fixup_phb

2015-07-31 Thread Hou Zhiqiang
Hi Dongsheng and Scott,

Do you have any comment?

 -Original Message-
 From: Zhiqiang Hou [mailto:b48...@freescale.com]
 Sent: 2015年7月21日 18:10
 To: ga...@kernel.crashing.org; linuxppc-dev@lists.ozlabs.org
 Cc: Hu Mingkai-B21284; Wang Dongsheng-B40534; Hou Zhiqiang-B48286
 Subject: [PATCH] c293/pci: remove hook pcibios_fixup_phb
 
 From: Hou Zhiqiang b48...@freescale.com
 
 The c293pcie board is an endpoint device, and it does't need PM.
 
 Signed-off-by: Hou Zhiqiang b48...@freescale.com
 ---
  arch/powerpc/platforms/85xx/c293pcie.c | 1 -
  1 file changed, 1 deletion(-)
 
 diff --git a/arch/powerpc/platforms/85xx/c293pcie.c
 b/arch/powerpc/platforms/85xx/c293pcie.c
 index 84476b6..213d5b8 100644
 --- a/arch/powerpc/platforms/85xx/c293pcie.c
 +++ b/arch/powerpc/platforms/85xx/c293pcie.c
 @@ -68,7 +68,6 @@ define_machine(c293_pcie) {
   .init_IRQ   = c293_pcie_pic_init,
  #ifdef CONFIG_PCI
   .pcibios_fixup_bus  = fsl_pcibios_fixup_bus,
 - .pcibios_fixup_phb  = fsl_pcibios_fixup_phb,
  #endif
   .get_irq= mpic_get_irq,
   .restart= fsl_rstcr_restart,
 --
 2.1.0.27.g96db324

Thanks,
Zhiqiang
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [PATCH] powerpc/fsl-pci: fix pcie range issue for some P1/P2 boards

2015-07-30 Thread Hou Zhiqiang
Hi Scott,

 -Original Message-
 From: Wood Scott-B07421
 Sent: 2015年7月29日 10:35
 To: Hou Zhiqiang-B48286
 Cc: linuxppc-dev@lists.ozlabs.org; b...@kernel.crashing.org;
 pau...@samba.org; m...@ellerman.id.au; Hu Mingkai-B21284
 Subject: Re: [PATCH] powerpc/fsl-pci: fix pcie range issue for some P1/P2
 boards
 
 On Tue, 2015-07-28 at 21:34 -0500, Hou Zhiqiang-B48286 wrote:
  Hi Scott and all,
 
  Please ignore this patch!
 
 Did you figure out what was actually causing you to see CPU stalls?


This issue fixed by cf4d1cf5ac5e7d2b886af6ed906ea0dcdc5b6855 in upstream.
 
 -Scott

Thanks,
Zhiqiang
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [PATCH] powerpc/fsl-pci: fix pcie range issue for some P1/P2 boards

2015-07-28 Thread Hou Zhiqiang
Hi Scott and all,

Please ignore this patch!

 -Original Message-
 From: Wood Scott-B07421
 Sent: 2015年7月25日 10:48
 To: Hou Zhiqiang-B48286
 Cc: linuxppc-dev@lists.ozlabs.org; b...@kernel.crashing.org;
 pau...@samba.org; m...@ellerman.id.au; Hu Mingkai-B21284
 Subject: Re: [PATCH] powerpc/fsl-pci: fix pcie range issue for some P1/P2
 boards
 
 On Wed, 2015-07-22 at 18:08 +0800, Zhiqiang Hou wrote:
 
  From: Hou Zhiqiang b48...@freescale.com
 
 You CCed this to
 b21...@freescale.com.  Who is that?  It would be nice to use friendly
 e-mail addresses, but at least include the name along with the e-mail
 address.
 
 I suggest CCing the people who added these device trees.
 
  Impact board list:
  P1020MBG-PC. P1022DS, P2020RDB
  All above boards have its PCIE memory range less than 0xbfff_,
 
 If you mean that the physical address of the memory region is =
 0xbfff_, I don't see the relevance.

  but in dts its boundary value was 0xe000. Both of them was maped
  to the same boundary 0xe000 which was Overlapped and crossed.
 
 By boundary do you mean the PCIe bus address?  Why is it a problem for
 these independent PCIe root complexes to have the same PCIe bus addresses?


Yes, you're right. It isn't an issue using the same PCIe bus addresses. 
 
   Cpu will access the illicit memery addr and detect error then lead to
  cpu stall.  So update dts for these boards.
 
 What is illicit about it?
 
 Why isn't the problem seen in the 36-bit device trees, which do the same
 thing?
 
 -Scott

Thanks,
Zhiqiang
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH V5] mtd: m25p80: modify the name of mtd_info

2014-04-28 Thread Hou Zhiqiang
To specify spi flash layouts by mtdparts=... in cmdline, we must
give mtd_info a fixed name, because the cmdlinepart's parser will
match the name of mtd_info given in cmdline.
Now, if it use DT, the mtd_info's name will be spi-dev-name. It
consists of spi_master-bus_num, and the spi_master-bus_num maybe
dynamically fetched. So, in this case, replace the component bus_num
with the physical address of spi master.

Signed-off-by: Hou Zhiqiang b48...@freescale.com
---
V5:
Rebase on the latest l2-mtd tree.
V4:
add check no-NULL for pointer of master's device node, and if it failed
to get physcial address of the master, then name the mtd_info by the
name of spi-dev.
V3:
Fix a bug, matching unsigned long long with %llx.
V2:
1. Fix some code style issue.
2. Cast physical address to unsigned long long.

 drivers/mtd/devices/m25p80.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 1557d8f..329aa2c 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -26,6 +26,7 @@
 #include linux/spi/spi.h
 #include linux/spi/flash.h
 #include linux/mtd/spi-nor.h
+#include linux/of_address.h
 
 #defineMAX_CMD_SIZE6
 struct m25p {
@@ -196,6 +197,8 @@ static int m25p_probe(struct spi_device *spi)
struct m25p *flash;
struct spi_nor *nor;
enum read_mode mode = SPI_NOR_NORMAL;
+   struct resource res;
+   struct device_node *mnp = spi-master-dev.of_node;
int ret;
 
flash = devm_kzalloc(spi-dev, sizeof(*flash), GFP_KERNEL);
@@ -228,6 +231,17 @@ static int m25p_probe(struct spi_device *spi)
data = dev_get_platdata(spi-dev);
ppdata.of_node = spi-dev.of_node;
 
+   if (mnp) {
+   ret = of_address_to_resource(mnp, 0, res);
+   if (!ret) {
+   flash-mtd.name = kasprintf(GFP_KERNEL, spi%llx.%d,
+   (unsigned long long)res.start,
+   spi-chip_select);
+   if (!flash-mtd.name)
+   return -ENOMEM;
+   }
+   }
+
return mtd_device_parse_register(flash-mtd, NULL, ppdata,
data ? data-parts : NULL,
data ? data-nr_parts : 0);
-- 
1.8.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH V4] mtd: m25p80: Modify the name of mtd_info

2014-04-21 Thread Hou Zhiqiang
To specify spi flash layouts by mtdparts=... in cmdline, we must
give mtd_info a fixed name,because the cmdlinepart's parser will
match the name of mtd_info given in cmdline.
Now, if use DT, the mtd_info's name will be spi-dev-name. It
consists of spi_master-bus_num, and the spi_master-bus_num maybe
dynamically fetched. So, in this case, replace the component bus_num
with thei physical address of spi master.

Signed-off-by: Hou Zhiqiang b48...@freescale.com
---
V4:
add check no-NULL for pointer of master's device node, and if it failed
to get physcial address of the master, then name the mtd_info by the
name of spi-dev.
V3:
Fix a bug, matching unsigned long long with %llx.
V2:
1. Fix some code style issue.
2. Cast physical address to unsigned long long.

 drivers/mtd/devices/m25p80.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 7eda71d..998b283 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -934,9 +934,11 @@ static int m25p_probe(struct spi_device *spi)
struct flash_platform_data  *data;
struct m25p *flash;
struct flash_info   *info;
-   unsignedi;
+   unsignedi, ret;
struct mtd_part_parser_data ppdata;
struct device_node *np = spi-dev.of_node;
+   struct resource res;
+   struct device_node *mnp = spi-master-dev.of_node;
 
/* Platform data helps sort out which chip type we have, as
 * well as how this board partitions it.  If we don't have
@@ -1009,7 +1011,17 @@ static int m25p_probe(struct spi_device *spi)
 
if (data  data-name)
flash-mtd.name = data-name;
-   else
+   else if (mnp) {
+   ret = of_address_to_resource(mnp, 0, res);
+   if (!ret) {
+   flash-mtd.name = kasprintf(GFP_KERNEL, spi%llx.%d,
+   (unsigned long long)res.start,
+   spi-chip_select);
+   if (!flash-mtd.name)
+   return -ENOMEM;
+   } else
+   dev_dbg(spi-dev, failed to get spi master 
resource\n);
+   } else
flash-mtd.name = dev_name(spi-dev);
 
flash-mtd.type = MTD_NORFLASH;
-- 
1.8.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[v2] mtd: m25p80: Modify the name of mtd_info

2014-03-22 Thread Hou Zhiqiang
To specify spi flash layouts by mtdparts=... in cmdline, we must
give mtd_info a fixed name,because the cmdlinepart's parser will
match the name of mtd_info given in cmdline.
Now, if use DT, the mtd_info's name will be spi-dev-name. It
consists of spi_master-bus_num, and the spi_master-bus_num maybe
dynamically fetched. So, in this case, replace the component bus_num
with thei physical address of spi master.

Signed-off-by: Hou Zhiqiang b48...@freescale.com
---
v2:
1. Fix some code style issue.
2. Cast physical address to unsigned long long.

 drivers/mtd/devices/m25p80.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 7eda71d..cbb04aa 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -30,6 +30,7 @@
 #include linux/mtd/cfi.h
 #include linux/mtd/mtd.h
 #include linux/mtd/partitions.h
+#include linux/of_address.h
 #include linux/of_platform.h
 
 #include linux/spi/spi.h
@@ -934,9 +935,11 @@ static int m25p_probe(struct spi_device *spi)
struct flash_platform_data  *data;
struct m25p *flash;
struct flash_info   *info;
-   unsignedi;
+   unsignedi, ret;
struct mtd_part_parser_data ppdata;
struct device_node *np = spi-dev.of_node;
+   struct resource res;
+   struct device_node *mnp = spi-master-dev.of_node;
 
/* Platform data helps sort out which chip type we have, as
 * well as how this board partitions it.  If we don't have
@@ -1009,8 +1012,18 @@ static int m25p_probe(struct spi_device *spi)
 
if (data  data-name)
flash-mtd.name = data-name;
-   else
-   flash-mtd.name = dev_name(spi-dev);
+   else {
+   ret = of_address_to_resource(mnp, 0, res);
+   if (ret) {
+   dev_err(spi-dev, failed to get spi master 
resource\n);
+   return ret;
+   }
+   flash-mtd.name = kasprintf(GFP_KERNEL, spi%x.%d,
+   (unsigned long long)res.start,
+   spi-chip_select);
+   if (!flash-mtd.name)
+   return -ENOMEM;
+   }
 
flash-mtd.type = MTD_NORFLASH;
flash-mtd.writesize = 1;
-- 
1.8.5


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[v3] mtd: m25p80: Modify the name of mtd_info

2014-03-22 Thread Hou Zhiqiang
To specify spi flash layouts by mtdparts=... in cmdline, we must
give mtd_info a fixed name,because the cmdlinepart's parser will
match the name of mtd_info given in cmdline.
Now, if use DT, the mtd_info's name will be spi-dev-name. It
consists of spi_master-bus_num, and the spi_master-bus_num maybe
dynamically fetched. So, in this case, replace the component bus_num
with thei physical address of spi master.

Signed-off-by: Hou Zhiqiang b48...@freescale.com
---
v3:
Fix a bug, matching unsigned long long with %llx.
v2:
1. Fix some code style issue.
2. Cast physical address to unsigned long long.

 drivers/mtd/devices/m25p80.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 7eda71d..695890e 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -30,6 +30,7 @@
 #include linux/mtd/cfi.h
 #include linux/mtd/mtd.h
 #include linux/mtd/partitions.h
+#include linux/of_address.h
 #include linux/of_platform.h
 
 #include linux/spi/spi.h
@@ -934,9 +935,11 @@ static int m25p_probe(struct spi_device *spi)
struct flash_platform_data  *data;
struct m25p *flash;
struct flash_info   *info;
-   unsignedi;
+   unsignedi, ret;
struct mtd_part_parser_data ppdata;
struct device_node *np = spi-dev.of_node;
+   struct resource res;
+   struct device_node *mnp = spi-master-dev.of_node;
 
/* Platform data helps sort out which chip type we have, as
 * well as how this board partitions it.  If we don't have
@@ -1009,8 +1012,18 @@ static int m25p_probe(struct spi_device *spi)
 
if (data  data-name)
flash-mtd.name = data-name;
-   else
-   flash-mtd.name = dev_name(spi-dev);
+   else {
+   ret = of_address_to_resource(mnp, 0, res);
+   if (ret) {
+   dev_err(spi-dev, failed to get spi master 
resource\n);
+   return ret;
+   }
+   flash-mtd.name = kasprintf(GFP_KERNEL, spi%llx.%d,
+   (unsigned long long)res.start,
+   spi-chip_select);
+   if (!flash-mtd.name)
+   return -ENOMEM;
+   }
 
flash-mtd.type = MTD_NORFLASH;
flash-mtd.writesize = 1;
-- 
1.8.5


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] mtd: m25p80: Modify the name of mtd_info

2014-03-21 Thread Hou Zhiqiang
To specify spi flash layouts by mtdparts=... in cmdline, we must
give mtd_info a fixed name,because the cmdlinepart's parser will
match the name of mtd_info given in cmdline.
Now, if use DT, the mtd_info's name will be spi-dev-name. It
consists of spi_master-bus_num, and the spi_master-bus_num maybe
dynamically fetched. So, in this case, replace the component bus_num
with thei physical address of spi master.

Signed-off-by: Hou Zhiqiang b48...@freescale.com
---
 drivers/mtd/devices/m25p80.c | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 7eda71d..64450a2 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -30,6 +30,7 @@
 #include linux/mtd/cfi.h
 #include linux/mtd/mtd.h
 #include linux/mtd/partitions.h
+#include linux/of_address.h
 #include linux/of_platform.h
 
 #include linux/spi/spi.h
@@ -934,9 +935,11 @@ static int m25p_probe(struct spi_device *spi)
struct flash_platform_data  *data;
struct m25p *flash;
struct flash_info   *info;
-   unsignedi;
+   unsignedi, ret;
struct mtd_part_parser_data ppdata;
struct device_node *np = spi-dev.of_node;
+   struct resource res;
+   struct device_node *mnp = spi-master-dev.of_node;
 
/* Platform data helps sort out which chip type we have, as
 * well as how this board partitions it.  If we don't have
@@ -1009,8 +1012,17 @@ static int m25p_probe(struct spi_device *spi)
 
if (data  data-name)
flash-mtd.name = data-name;
-   else
-   flash-mtd.name = dev_name(spi-dev);
+   else{
+   ret = of_address_to_resource(mnp, 0, res);
+   if (ret) {
+   dev_err(spi-dev, failed to get spi master 
resource\n);
+   return ret;
+   }
+   flash-mtd.name = kasprintf(GFP_KERNEL, spi%x.%d,
+   (unsigned)res.start, spi-chip_select);
+   if (!flash-mtd.name)
+   return -ENOMEM;
+   }
 
flash-mtd.type = MTD_NORFLASH;
flash-mtd.writesize = 1;
-- 
1.8.5


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v2] mtd: m25p80: Make the name of mtd_info fixed

2014-01-25 Thread Hou Zhiqiang
To give spi flash layout using mtdparts=... in cmdline, we must
give mtd_info a fixed name,because the cmdlinepart's parser will
match the name given in cmdline with the mtd_info.

Now, if use OF node, mtd_info's name will be spi-dev-name. It
consists of spi_master-bus_num, and the spi_master-bus_num maybe
dynamically fetched.
So, give the mtd_info a new fiexd name name.cs, name is name of
spi_device_id and cs is chip-select in spi_dev.

Signed-off-by: Hou Zhiqiang b48...@freescale.com
---
v2:
 - add check for return value of function kasprintf.
 - whether the spi_master-bus_num is dynamical is determined by spi
   controller driver, and it can't be check in this driver. So, we can
   not initial the mtd_info's name by distinguishing the spi_master
   bus_num dynamically-allocated or not.

 drivers/mtd/devices/m25p80.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index eb558e8..1f494d2 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -1011,8 +1011,12 @@ static int m25p_probe(struct spi_device *spi)
 
if (data  data-name)
flash-mtd.name = data-name;
-   else
-   flash-mtd.name = dev_name(spi-dev);
+   else {
+   flash-mtd.name = kasprintf(GFP_KERNEL, %s.%d,
+   id-name, spi-chip_select);
+   if (!flash-mtd.name)
+   return -ENOMEM;
+   }
 
flash-mtd.type = MTD_NORFLASH;
flash-mtd.writesize = 1;
-- 
1.8.4.1


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] mtd: m25p80: Make the name of mtd_info fixed

2014-01-06 Thread Hou Zhiqiang
To give spi flash layout using mtdparts=... in cmdline, we must
give mtd_info a fixed name,because the cmdlinepart's parser will
match the name given in cmdline with the mtd_info.

Now, if use OF node, mtd_info's name will be spi-dev-name. It
consists of spi_master-bus_num, and the spi_master-bus_num maybe
dynamically fetched.
So, give the mtd_info a new fiexd name name.cs, name is name of
spi_device_id and cs is chip-select in spi_dev.

Signed-off-by: Hou Zhiqiang b48...@freescale.com
---
 drivers/mtd/devices/m25p80.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index eb558e8..d1ed480 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -1012,7 +1012,8 @@ static int m25p_probe(struct spi_device *spi)
if (data  data-name)
flash-mtd.name = data-name;
else
-   flash-mtd.name = dev_name(spi-dev);
+   flash-mtd.name = kasprintf(GFP_KERNEL, %s.%d,
+   id-name, spi-chip_select);
 
flash-mtd.type = MTD_NORFLASH;
flash-mtd.writesize = 1;
-- 
1.8.4.1


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] spi/fsl-espi: Add Power Management support for eSPI controller

2013-12-11 Thread Hou Zhiqiang
Add PM support for eSPI controller using callback function suspend
and resume in .driver of platform_driver.

Signed-off-by: Hou Zhiqiang b48...@freescale.com
---
 drivers/spi/spi-fsl-espi.c | 57 ++
 1 file changed, 57 insertions(+)

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 8106006..9c3fe70 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -727,6 +727,59 @@ static int of_fsl_espi_remove(struct platform_device *dev)
return mpc8xxx_spi_remove(dev-dev);
 }
 
+#ifdef CONFIG_PM
+static int of_fsl_espi_suspend(struct device *dev, pm_message_t state)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct spi_master *master = platform_get_drvdata(pdev);
+   struct mpc8xxx_spi *mpc8xxx_spi;
+   struct fsl_espi_reg *reg_base;
+   u32 regval;
+
+   mpc8xxx_spi = spi_master_get_devdata(master);
+   reg_base = mpc8xxx_spi-reg_base;
+
+   regval = mpc8xxx_spi_read_reg(reg_base-mode);
+   regval = ~(SPMODE_ENABLE);
+   mpc8xxx_spi_write_reg(reg_base-mode, regval);
+
+   regval = mpc8xxx_spi_read_reg(reg_base-mode);
+
+   return 0;
+}
+
+static int of_fsl_espi_resume(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
+   struct spi_master *master = platform_get_drvdata(pdev);
+   struct mpc8xxx_spi *mpc8xxx_spi;
+   struct fsl_espi_reg *reg_base;
+   u32 regval;
+   int i;
+
+   mpc8xxx_spi = spi_master_get_devdata(master);
+   reg_base = mpc8xxx_spi-reg_base;
+
+   /* SPI controller initializations */
+   mpc8xxx_spi_write_reg(reg_base-mode, 0);
+   mpc8xxx_spi_write_reg(reg_base-mask, 0);
+   mpc8xxx_spi_write_reg(reg_base-command, 0);
+   mpc8xxx_spi_write_reg(reg_base-event, 0x);
+
+   /* Init eSPI CS mode register */
+   for (i = 0; i  pdata-max_chipselect; i++)
+   mpc8xxx_spi_write_reg(reg_base-csmode[i], CSMODE_INIT_VAL);
+
+   /* Enable SPI interface */
+   regval = pdata-initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE;
+
+   mpc8xxx_spi_write_reg(reg_base-mode, regval);
+
+   return 0;
+}
+#endif /* CONFIG_PM */
+
 static const struct of_device_id of_fsl_espi_match[] = {
{ .compatible = fsl,mpc8536-espi },
{}
@@ -738,6 +791,10 @@ static struct platform_driver fsl_espi_driver = {
.name = fsl_espi,
.owner = THIS_MODULE,
.of_match_table = of_fsl_espi_match,
+#ifdef CONFIG_PM
+   .suspend= of_fsl_espi_suspend,
+   .resume = of_fsl_espi_resume,
+#endif
},
.probe  = of_fsl_espi_probe,
.remove = of_fsl_espi_remove,
-- 
1.8.4.1


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] mtd: m25p80: Add Power Management support

2013-12-11 Thread Hou Zhiqiang
Add PM support using callback function suspend and resume in .driver of
spi_driver.

Signed-off-by: Hou Zhiqiang b48...@freescale.com
---
 drivers/mtd/devices/m25p80.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 7eda71d..b0c2b8c 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -66,6 +66,8 @@
 
 /* Used for Spansion flashes only. */
 #defineOPCODE_BRWR 0x17/* Bank register write */
+#defineOPCODE_DP   0xb9/* Enter deep power down mode */
+#defineOPCODE_RES  0xab/* Exit deep power down mode */
 
 /* Status Register bits. */
 #defineSR_WIP  1   /* Write in progress */
@@ -1128,11 +1130,46 @@ static int m25p_remove(struct spi_device *spi)
return mtd_device_unregister(flash-mtd);
 }
 
+#ifdef CONFIG_PM
+static int m25p_suspend(struct device *dev, pm_message_t mesg)
+{
+   struct m25p *flash = dev_get_drvdata(dev);
+   int ret;
+
+   flash-command[0] = OPCODE_DP;
+   mutex_lock(flash-lock);
+   /* Wait until finished previous write/erase command. */
+   ret = wait_till_ready(flash);
+   if (ret) {
+   mutex_unlock(flash-lock);
+   return ret;
+   }
+   ret = spi_write(flash-spi, flash-command, 1);
+   mutex_unlock(flash-lock);
+
+   return ret;
+}
+
+static int m25p_resume(struct device *dev)
+{
+   struct m25p *flash = dev_get_drvdata(dev);
+   int ret;
+
+   flash-command[0] = OPCODE_RES;
+   ret = spi_write(flash-spi, flash-command, 1);
+
+   return ret;
+}
+#endif /* CONFIG_PM */
 
 static struct spi_driver m25p80_driver = {
.driver = {
.name   = m25p80,
.owner  = THIS_MODULE,
+#ifdef CONFIG_PM
+   .suspend = m25p_suspend,
+   .resume = m25p_resume,
+#endif
},
.id_table   = m25p_ids,
.probe  = m25p_probe,
-- 
1.8.4.1


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v2] spi/fsl-espi: Add Power Management support for eSPI controller

2013-12-11 Thread Hou Zhiqiang
Add PM support for eSPI controller using callback function suspend
and resume in .driver.pm of platform_driver.

Signed-off-by: Hou Zhiqiang b48...@freescale.com
---
v2:
 - Replace .driver.suspend and .driver.resume with .driver.pm
 - Use CONFIG_PM_SLEEP instead of CONFIG_PM
 - Add spi_master_suspend and spi_master_resume

 drivers/spi/spi-fsl-espi.c | 61 ++
 1 file changed, 61 insertions(+)

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 8106006..428dc7a 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -727,6 +727,66 @@ static int of_fsl_espi_remove(struct platform_device *dev)
return mpc8xxx_spi_remove(dev-dev);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int of_fsl_espi_suspend(struct device *dev)
+{
+   struct spi_master *master = dev_get_drvdata(dev);
+   struct mpc8xxx_spi *mpc8xxx_spi;
+   struct fsl_espi_reg *reg_base;
+   u32 regval;
+   int ret;
+
+   mpc8xxx_spi = spi_master_get_devdata(master);
+   reg_base = mpc8xxx_spi-reg_base;
+
+   ret = spi_master_suspend(master);
+   if (ret) {
+   dev_warn(dev, cannot suspend master\n);
+   return ret;
+   }
+
+   regval = mpc8xxx_spi_read_reg(reg_base-mode);
+   regval = ~SPMODE_ENABLE;
+   mpc8xxx_spi_write_reg(reg_base-mode, regval);
+
+   return 0;
+}
+
+static int of_fsl_espi_resume(struct device *dev)
+{
+   struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
+   struct spi_master *master = dev_get_drvdata(dev);
+   struct mpc8xxx_spi *mpc8xxx_spi;
+   struct fsl_espi_reg *reg_base;
+   u32 regval;
+   int i;
+
+   mpc8xxx_spi = spi_master_get_devdata(master);
+   reg_base = mpc8xxx_spi-reg_base;
+
+   /* SPI controller initializations */
+   mpc8xxx_spi_write_reg(reg_base-mode, 0);
+   mpc8xxx_spi_write_reg(reg_base-mask, 0);
+   mpc8xxx_spi_write_reg(reg_base-command, 0);
+   mpc8xxx_spi_write_reg(reg_base-event, 0x);
+
+   /* Init eSPI CS mode register */
+   for (i = 0; i  pdata-max_chipselect; i++)
+   mpc8xxx_spi_write_reg(reg_base-csmode[i], CSMODE_INIT_VAL);
+
+   /* Enable SPI interface */
+   regval = pdata-initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE;
+
+   mpc8xxx_spi_write_reg(reg_base-mode, regval);
+
+   return spi_master_resume(master);
+}
+#endif /* CONFIG_PM_SLEEP */
+
+static const struct dev_pm_ops espi_pm = {
+   SET_SYSTEM_SLEEP_PM_OPS(of_fsl_espi_suspend, of_fsl_espi_resume)
+};
+
 static const struct of_device_id of_fsl_espi_match[] = {
{ .compatible = fsl,mpc8536-espi },
{}
@@ -738,6 +798,7 @@ static struct platform_driver fsl_espi_driver = {
.name = fsl_espi,
.owner = THIS_MODULE,
.of_match_table = of_fsl_espi_match,
+   .pm = espi_pm,
},
.probe  = of_fsl_espi_probe,
.remove = of_fsl_espi_remove,
-- 
1.8.4.1


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v2] mtd: m25p80: Add Power Management support

2013-12-11 Thread Hou Zhiqiang
Add PM support using callback function suspend and resume in
.driver.pm of spi_driver.

Signed-off-by: Hou Zhiqiang b48...@freescale.com
---
v2:
 - Replace .driver.suspend and .driver.resume with .driver.pm
 - Use CONFIG_PM_SLEEP instead of CONFIG_PM

 drivers/mtd/devices/m25p80.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 7eda71d..eb558e8 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -66,6 +66,8 @@
 
 /* Used for Spansion flashes only. */
 #defineOPCODE_BRWR 0x17/* Bank register write */
+#defineOPCODE_DP   0xb9/* Enter deep power down mode */
+#defineOPCODE_RES  0xab/* Exit deep power down mode */
 
 /* Status Register bits. */
 #defineSR_WIP  1   /* Write in progress */
@@ -1128,11 +1130,46 @@ static int m25p_remove(struct spi_device *spi)
return mtd_device_unregister(flash-mtd);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int m25p_suspend(struct device *dev)
+{
+   struct m25p *flash = dev_get_drvdata(dev);
+   int ret;
+
+   flash-command[0] = OPCODE_DP;
+   mutex_lock(flash-lock);
+   /* Wait until finished previous write/erase command. */
+   ret = wait_till_ready(flash);
+   if (ret) {
+   mutex_unlock(flash-lock);
+   return ret;
+   }
+   ret = spi_write(flash-spi, flash-command, 1);
+   mutex_unlock(flash-lock);
+
+   return ret;
+}
+
+static int m25p_resume(struct device *dev)
+{
+   struct m25p *flash = dev_get_drvdata(dev);
+   int ret;
+
+   flash-command[0] = OPCODE_RES;
+
+   return spi_write(flash-spi, flash-command, 1);
+}
+#endif /* CONFIG_PM_SLEEP */
+
+static const struct dev_pm_ops m25p_pm = {
+   SET_SYSTEM_SLEEP_PM_OPS(m25p_suspend, m25p_resume)
+};
 
 static struct spi_driver m25p80_driver = {
.driver = {
.name   = m25p80,
.owner  = THIS_MODULE,
+   .pm = m25p_pm,
},
.id_table   = m25p_ids,
.probe  = m25p_probe,
-- 
1.8.4.1


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev