linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: "Mark A. Greer" <mgreer@mvista.com>
Cc: linuxppc-dev <Linuxppc-dev@ozlabs.org>
Subject: Re: [PATCH 1/4] powerpc: mv64x60 - Use early_* PCI accessors for hotswap reg
Date: Thu, 17 Jan 2008 09:48:59 +1100	[thread overview]
Message-ID: <1200523739.6755.33.camel@pasglop> (raw)
In-Reply-To: <20080114225150.GB21940@mag.az.mvista.com>


On Mon, 2008-01-14 at 15:51 -0700, Mark A. Greer wrote:
> From: Mark A. Greer <mgreer@mvista.com>
> 
> The mv64x60 Hotswap register is on the first hose of the mv64x60
> hostbridge.  To access it, manually find the hose structure and
> use the early_* PCI accessor routines because the hostbridge is
> normally hidden.

Can't we unhide the NB instead ?

Cheers,
Ben.

> Signed-off-by: Mark A. Greer <mgreer@mvista.com>
> ---
>  arch/powerpc/sysdev/mv64x60.h     |   22 ++++++++++++++++++++++
>  arch/powerpc/sysdev/mv64x60_pci.c |   25 +++++++++++++++----------
>  2 files changed, 37 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/powerpc/sysdev/mv64x60.h b/arch/powerpc/sysdev/mv64x60.h
> index 4f618fa..27e22f4 100644
> --- a/arch/powerpc/sysdev/mv64x60.h
> +++ b/arch/powerpc/sysdev/mv64x60.h
> @@ -3,10 +3,32 @@
>  
>  #include <linux/init.h>
>  
> +#include <asm/prom.h>
> +#include <asm/pci-bridge.h>
> +
>  extern void __init mv64x60_init_irq(void);
>  extern unsigned int mv64x60_get_irq(void);
>  
>  extern void __init mv64x60_pci_init(void);
>  extern void __init mv64x60_init_early(void);
>  
> +static inline struct pci_controller *mv64x60_find_hose(u32 idx)
> +{
> +	struct device_node *phb;
> +	struct pci_controller *hose;
> +	const u32 *prop;
> +	int len;
> +
> +	for_each_compatible_node(phb, "pci", "marvell,mv64360-pci") {
> +		prop = of_get_property(phb, "cell-index", &len);
> +		if (prop && (len == sizeof(prop)) && (*prop == idx)) {
> +			hose = pci_find_hose_for_OF_device(phb);
> +			of_node_put(phb);
> +			return hose;
> +		}
> +	}
> +
> +	return NULL;
> +}
> +
>  #endif /* __MV64X60_H__ */
> diff --git a/arch/powerpc/sysdev/mv64x60_pci.c b/arch/powerpc/sysdev/mv64x60_pci.c
> index 1456015..2115177 100644
> --- a/arch/powerpc/sysdev/mv64x60_pci.c
> +++ b/arch/powerpc/sysdev/mv64x60_pci.c
> @@ -17,6 +17,8 @@
>  #include <asm/prom.h>
>  #include <asm/pci-bridge.h>
>  
> +#include <sysdev/mv64x60.h>
> +
>  #define PCI_HEADER_TYPE_INVALID		0x7f	/* Invalid PCI header type */
>  
>  #ifdef CONFIG_SYSFS
> @@ -24,11 +26,12 @@
>  #define MV64X60_VAL_LEN_MAX		11
>  #define MV64X60_PCICFG_CPCI_HOTSWAP	0x68
>  
> +/* cPCI Hotswap register only supported on PCI 0 interface */
>  static ssize_t mv64x60_hs_reg_read(struct kobject *kobj,
>  				   struct bin_attribute *attr, char *buf,
>  				   loff_t off, size_t count)
>  {
> -	struct pci_dev *phb;
> +	struct pci_controller *hose;
>  	u32 v;
>  
>  	if (off > 0)
> @@ -36,11 +39,12 @@ static ssize_t mv64x60_hs_reg_read(struct kobject *kobj,
>  	if (count < MV64X60_VAL_LEN_MAX)
>  		return -EINVAL;
>  
> -	phb = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
> -	if (!phb)
> +	hose = mv64x60_find_hose(0);
> +	if (!hose)
>  		return -ENODEV;
> -	pci_read_config_dword(phb, MV64X60_PCICFG_CPCI_HOTSWAP, &v);
> -	pci_dev_put(phb);
> +
> +	early_read_config_dword(hose, 0, PCI_DEVFN(0, 0),
> +			MV64X60_PCICFG_CPCI_HOTSWAP, &v);
>  
>  	return sprintf(buf, "0x%08x\n", v);
>  }
> @@ -49,7 +53,7 @@ static ssize_t mv64x60_hs_reg_write(struct kobject *kobj,
>  				    struct bin_attribute *attr, char *buf,
>  				    loff_t off, size_t count)
>  {
> -	struct pci_dev *phb;
> +	struct pci_controller *hose;
>  	u32 v;
>  
>  	if (off > 0)
> @@ -60,11 +64,12 @@ static ssize_t mv64x60_hs_reg_write(struct kobject *kobj,
>  	if (sscanf(buf, "%i", &v) != 1)
>  		return -EINVAL;
>  
> -	phb = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
> -	if (!phb)
> +	hose = mv64x60_find_hose(0);
> +	if (!hose)
>  		return -ENODEV;
> -	pci_write_config_dword(phb, MV64X60_PCICFG_CPCI_HOTSWAP, v);
> -	pci_dev_put(phb);
> +
> +	early_write_config_dword(hose, 0, PCI_DEVFN(0, 0),
> +			MV64X60_PCICFG_CPCI_HOTSWAP, v);
>  
>  	return count;
>  }
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

  parent reply	other threads:[~2008-01-16 22:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-14 22:51 [PATCH 1/4] powerpc: mv64x60 - Use early_* PCI accessors for hotswap reg Mark A. Greer
2008-01-14 22:58 ` [PATCH 2/4] powerpc: mv64x60 - Exit when no hs_reg_valid property Mark A. Greer
2008-01-14 22:59 ` [PATCH 3/4] powerpc: Katana750i - Add DTS file Mark A. Greer
2008-01-14 23:34   ` David Gibson
2008-01-15 19:08     ` Mark A. Greer
2008-01-16  0:22       ` David Gibson
2008-01-16 20:48         ` Mark A. Greer
2008-01-17  1:06           ` David Gibson
2008-01-17  2:28             ` Mark A. Greer
2008-01-16 22:04   ` [PATCH 3/4 v2] " Mark A. Greer
2008-01-14 23:00 ` [PATCH 4/4] powerpc: Katana750i - Add platform support Mark A. Greer
2008-01-14 23:33   ` Stephen Rothwell
2008-01-15 17:36     ` Mark A. Greer
2008-01-16 22:12   ` [PATCH 4/4 v2] " Mark A. Greer
2008-01-16 23:27     ` Stephen Rothwell
2008-01-17  0:35       ` Mark A. Greer
2008-01-17  1:58     ` David Gibson
2008-01-14 23:19 ` [PATCH 1/4] powerpc: mv64x60 - Use early_* PCI accessors for hotswap reg Stephen Rothwell
2008-01-15 17:20   ` Mark A. Greer
2008-01-14 23:21 ` Stephen Rothwell
2008-01-15 17:31   ` Mark A. Greer
2008-01-16 22:00 ` [PATCH 1/4 v2] " Mark A. Greer
2008-01-16 22:48 ` Benjamin Herrenschmidt [this message]
2008-01-17  0:47   ` [PATCH 1/4] " Mark A. Greer
2008-01-17  2:39     ` Benjamin Herrenschmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1200523739.6755.33.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=Linuxppc-dev@ozlabs.org \
    --cc=mgreer@mvista.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).