Re: [PATCH v5 15/22] sh: Move common PCI stuff to arch/sh/kernel

2016-07-06 Thread Yoshinori Sato
On Mon, 04 Jul 2016 10:55:12 +0900,
Rich Felker wrote:
> 
> On Mon, Jul 04, 2016 at 01:46:35AM +0900, Yoshinori Sato wrote:
> > Signed-off-by: Yoshinori Sato 
> > ---
> >  arch/sh/drivers/pci/Makefile |   2 -
> >  arch/sh/drivers/pci/common.c | 162 
> >  arch/sh/drivers/pci/pci.c| 320 
> >  arch/sh/kernel/Makefile  |   2 +
> >  arch/sh/kernel/pci-common.c  | 162 
> >  arch/sh/kernel/pci.c | 342 
> > +++
> >  6 files changed, 506 insertions(+), 484 deletions(-)
> >  delete mode 100644 arch/sh/drivers/pci/common.c
> >  delete mode 100644 arch/sh/drivers/pci/pci.c
> >  create mode 100644 arch/sh/kernel/pci-common.c
> >  create mode 100644 arch/sh/kernel/pci.c
> > 
> > diff --git a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile
> > index 82f0a33..fffbede 100644
> > --- a/arch/sh/drivers/pci/Makefile
> > +++ b/arch/sh/drivers/pci/Makefile
> > @@ -1,8 +1,6 @@
> >  #
> >  # Makefile for the PCI specific kernel interface routines under Linux.
> >  #
> > -obj-y  += common.o pci.o
> > -
> >  obj-$(CONFIG_CPU_SUBTYPE_SH7751)   += pci-sh7751.o ops-sh4.o
> >  obj-$(CONFIG_CPU_SUBTYPE_SH7751R)  += pci-sh7751.o ops-sh4.o
> >  obj-$(CONFIG_CPU_SUBTYPE_SH7763)   += pci-sh7780.o ops-sh4.o
> > diff --git a/arch/sh/drivers/pci/common.c b/arch/sh/drivers/pci/common.c
> > deleted file mode 100644
> > index dbf1381..000
> > --- a/arch/sh/drivers/pci/common.c
> > +++ /dev/null
> > @@ -1,162 +0,0 @@
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> > -
> > -/*
> > - * These functions are used early on before PCI scanning is done
> > - * and all of the pci_dev and pci_bus structures have been created.
> > - */
> > -static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
> > -   int top_bus, int busnr, int devfn)
> > -{
> > -   static struct pci_dev dev;
> > -   static struct pci_bus bus;
> > -
> > -   dev.bus = 
> > -   dev.sysdata = hose;
> > -   dev.devfn = devfn;
> > -   bus.number = busnr;
> > -   bus.sysdata = hose;
> > -   bus.ops = hose->pci_ops;
> > -
> > -   if(busnr != top_bus)
> > -   /* Fake a parent bus structure. */
> > -   bus.parent = 
> > -   else
> > -   bus.parent = NULL;
> > -
> > -   return 
> > -}
> > -
> > -#define EARLY_PCI_OP(rw, size, type)   
> > \
> > -int __init early_##rw##_config_##size(struct pci_channel *hose,
> > \
> > -   int top_bus, int bus, int devfn, int offset, type value)\
> > -{  \
> > -   return pci_##rw##_config_##size(\
> > -   fake_pci_dev(hose, top_bus, bus, devfn),\
> > -   offset, value); \
> > -}
> > -
> > -EARLY_PCI_OP(read, byte, u8 *)
> > -EARLY_PCI_OP(read, word, u16 *)
> > -EARLY_PCI_OP(read, dword, u32 *)
> > -EARLY_PCI_OP(write, byte, u8)
> > -EARLY_PCI_OP(write, word, u16)
> > -EARLY_PCI_OP(write, dword, u32)
> > -
> > -int __init pci_is_66mhz_capable(struct pci_channel *hose,
> > -   int top_bus, int current_bus)
> > -{
> > -   u32 pci_devfn;
> > -   unsigned short vid;
> > -   int cap66 = -1;
> > -   u16 stat;
> > -
> > -   printk(KERN_INFO "PCI: Checking 66MHz capabilities...\n");
> > -
> > -   for (pci_devfn = 0; pci_devfn < 0xff; pci_devfn++) {
> > -   if (PCI_FUNC(pci_devfn))
> > -   continue;
> > -   if (early_read_config_word(hose, top_bus, current_bus,
> > -  pci_devfn, PCI_VENDOR_ID, ) !=
> > -   PCIBIOS_SUCCESSFUL)
> > -   continue;
> > -   if (vid == 0x)
> > -   continue;
> > -
> > -   /* check 66MHz capability */
> > -   if (cap66 < 0)
> > -   cap66 = 1;
> > -   if (cap66) {
> > -   early_read_config_word(hose, top_bus, current_bus,
> > -  pci_devfn, PCI_STATUS, );
> > -   if (!(stat & PCI_STATUS_66MHZ)) {
> > -   printk(KERN_DEBUG
> > -  "PCI: %02x:%02x not 66MHz capable.\n",
> > -  current_bus, pci_devfn);
> > -   cap66 = 0;
> > -   break;
> > -   }
> > -   }
> > -   }
> > -
> > -   return cap66 > 0;
> > -}
> > -
> > -static void pcibios_enable_err(unsigned long __data)
> > -{
> > -   struct pci_channel *hose = (struct pci_channel *)__data;
> > -
> > -   del_timer(>err_timer);
> > -   printk(KERN_DEBUG "PCI: re-enabling error IRQ.\n");
> > -   enable_irq(hose->err_irq);
> > -}
> > -
> > -static void pcibios_enable_serr(unsigned long __data)
> > -{
> > -   struct pci_channel 

Re: [PATCH v5 15/22] sh: Move common PCI stuff to arch/sh/kernel

2016-07-06 Thread Yoshinori Sato
On Mon, 04 Jul 2016 10:55:12 +0900,
Rich Felker wrote:
> 
> On Mon, Jul 04, 2016 at 01:46:35AM +0900, Yoshinori Sato wrote:
> > Signed-off-by: Yoshinori Sato 
> > ---
> >  arch/sh/drivers/pci/Makefile |   2 -
> >  arch/sh/drivers/pci/common.c | 162 
> >  arch/sh/drivers/pci/pci.c| 320 
> >  arch/sh/kernel/Makefile  |   2 +
> >  arch/sh/kernel/pci-common.c  | 162 
> >  arch/sh/kernel/pci.c | 342 
> > +++
> >  6 files changed, 506 insertions(+), 484 deletions(-)
> >  delete mode 100644 arch/sh/drivers/pci/common.c
> >  delete mode 100644 arch/sh/drivers/pci/pci.c
> >  create mode 100644 arch/sh/kernel/pci-common.c
> >  create mode 100644 arch/sh/kernel/pci.c
> > 
> > diff --git a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile
> > index 82f0a33..fffbede 100644
> > --- a/arch/sh/drivers/pci/Makefile
> > +++ b/arch/sh/drivers/pci/Makefile
> > @@ -1,8 +1,6 @@
> >  #
> >  # Makefile for the PCI specific kernel interface routines under Linux.
> >  #
> > -obj-y  += common.o pci.o
> > -
> >  obj-$(CONFIG_CPU_SUBTYPE_SH7751)   += pci-sh7751.o ops-sh4.o
> >  obj-$(CONFIG_CPU_SUBTYPE_SH7751R)  += pci-sh7751.o ops-sh4.o
> >  obj-$(CONFIG_CPU_SUBTYPE_SH7763)   += pci-sh7780.o ops-sh4.o
> > diff --git a/arch/sh/drivers/pci/common.c b/arch/sh/drivers/pci/common.c
> > deleted file mode 100644
> > index dbf1381..000
> > --- a/arch/sh/drivers/pci/common.c
> > +++ /dev/null
> > @@ -1,162 +0,0 @@
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> > -
> > -/*
> > - * These functions are used early on before PCI scanning is done
> > - * and all of the pci_dev and pci_bus structures have been created.
> > - */
> > -static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
> > -   int top_bus, int busnr, int devfn)
> > -{
> > -   static struct pci_dev dev;
> > -   static struct pci_bus bus;
> > -
> > -   dev.bus = 
> > -   dev.sysdata = hose;
> > -   dev.devfn = devfn;
> > -   bus.number = busnr;
> > -   bus.sysdata = hose;
> > -   bus.ops = hose->pci_ops;
> > -
> > -   if(busnr != top_bus)
> > -   /* Fake a parent bus structure. */
> > -   bus.parent = 
> > -   else
> > -   bus.parent = NULL;
> > -
> > -   return 
> > -}
> > -
> > -#define EARLY_PCI_OP(rw, size, type)   
> > \
> > -int __init early_##rw##_config_##size(struct pci_channel *hose,
> > \
> > -   int top_bus, int bus, int devfn, int offset, type value)\
> > -{  \
> > -   return pci_##rw##_config_##size(\
> > -   fake_pci_dev(hose, top_bus, bus, devfn),\
> > -   offset, value); \
> > -}
> > -
> > -EARLY_PCI_OP(read, byte, u8 *)
> > -EARLY_PCI_OP(read, word, u16 *)
> > -EARLY_PCI_OP(read, dword, u32 *)
> > -EARLY_PCI_OP(write, byte, u8)
> > -EARLY_PCI_OP(write, word, u16)
> > -EARLY_PCI_OP(write, dword, u32)
> > -
> > -int __init pci_is_66mhz_capable(struct pci_channel *hose,
> > -   int top_bus, int current_bus)
> > -{
> > -   u32 pci_devfn;
> > -   unsigned short vid;
> > -   int cap66 = -1;
> > -   u16 stat;
> > -
> > -   printk(KERN_INFO "PCI: Checking 66MHz capabilities...\n");
> > -
> > -   for (pci_devfn = 0; pci_devfn < 0xff; pci_devfn++) {
> > -   if (PCI_FUNC(pci_devfn))
> > -   continue;
> > -   if (early_read_config_word(hose, top_bus, current_bus,
> > -  pci_devfn, PCI_VENDOR_ID, ) !=
> > -   PCIBIOS_SUCCESSFUL)
> > -   continue;
> > -   if (vid == 0x)
> > -   continue;
> > -
> > -   /* check 66MHz capability */
> > -   if (cap66 < 0)
> > -   cap66 = 1;
> > -   if (cap66) {
> > -   early_read_config_word(hose, top_bus, current_bus,
> > -  pci_devfn, PCI_STATUS, );
> > -   if (!(stat & PCI_STATUS_66MHZ)) {
> > -   printk(KERN_DEBUG
> > -  "PCI: %02x:%02x not 66MHz capable.\n",
> > -  current_bus, pci_devfn);
> > -   cap66 = 0;
> > -   break;
> > -   }
> > -   }
> > -   }
> > -
> > -   return cap66 > 0;
> > -}
> > -
> > -static void pcibios_enable_err(unsigned long __data)
> > -{
> > -   struct pci_channel *hose = (struct pci_channel *)__data;
> > -
> > -   del_timer(>err_timer);
> > -   printk(KERN_DEBUG "PCI: re-enabling error IRQ.\n");
> > -   enable_irq(hose->err_irq);
> > -}
> > -
> > -static void pcibios_enable_serr(unsigned long __data)
> > -{
> > -   struct pci_channel *hose = (struct pci_channel 

Re: [PATCH v5 15/22] sh: Move common PCI stuff to arch/sh/kernel

2016-07-03 Thread Rich Felker
On Mon, Jul 04, 2016 at 01:46:35AM +0900, Yoshinori Sato wrote:
> Signed-off-by: Yoshinori Sato 
> ---
>  arch/sh/drivers/pci/Makefile |   2 -
>  arch/sh/drivers/pci/common.c | 162 
>  arch/sh/drivers/pci/pci.c| 320 
>  arch/sh/kernel/Makefile  |   2 +
>  arch/sh/kernel/pci-common.c  | 162 
>  arch/sh/kernel/pci.c | 342 
> +++
>  6 files changed, 506 insertions(+), 484 deletions(-)
>  delete mode 100644 arch/sh/drivers/pci/common.c
>  delete mode 100644 arch/sh/drivers/pci/pci.c
>  create mode 100644 arch/sh/kernel/pci-common.c
>  create mode 100644 arch/sh/kernel/pci.c
> 
> diff --git a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile
> index 82f0a33..fffbede 100644
> --- a/arch/sh/drivers/pci/Makefile
> +++ b/arch/sh/drivers/pci/Makefile
> @@ -1,8 +1,6 @@
>  #
>  # Makefile for the PCI specific kernel interface routines under Linux.
>  #
> -obj-y+= common.o pci.o
> -
>  obj-$(CONFIG_CPU_SUBTYPE_SH7751) += pci-sh7751.o ops-sh4.o
>  obj-$(CONFIG_CPU_SUBTYPE_SH7751R)+= pci-sh7751.o ops-sh4.o
>  obj-$(CONFIG_CPU_SUBTYPE_SH7763) += pci-sh7780.o ops-sh4.o
> diff --git a/arch/sh/drivers/pci/common.c b/arch/sh/drivers/pci/common.c
> deleted file mode 100644
> index dbf1381..000
> --- a/arch/sh/drivers/pci/common.c
> +++ /dev/null
> @@ -1,162 +0,0 @@
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -/*
> - * These functions are used early on before PCI scanning is done
> - * and all of the pci_dev and pci_bus structures have been created.
> - */
> -static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
> - int top_bus, int busnr, int devfn)
> -{
> - static struct pci_dev dev;
> - static struct pci_bus bus;
> -
> - dev.bus = 
> - dev.sysdata = hose;
> - dev.devfn = devfn;
> - bus.number = busnr;
> - bus.sysdata = hose;
> - bus.ops = hose->pci_ops;
> -
> - if(busnr != top_bus)
> - /* Fake a parent bus structure. */
> - bus.parent = 
> - else
> - bus.parent = NULL;
> -
> - return 
> -}
> -
> -#define EARLY_PCI_OP(rw, size, type) \
> -int __init early_##rw##_config_##size(struct pci_channel *hose,  
> \
> - int top_bus, int bus, int devfn, int offset, type value)\
> -{\
> - return pci_##rw##_config_##size(\
> - fake_pci_dev(hose, top_bus, bus, devfn),\
> - offset, value); \
> -}
> -
> -EARLY_PCI_OP(read, byte, u8 *)
> -EARLY_PCI_OP(read, word, u16 *)
> -EARLY_PCI_OP(read, dword, u32 *)
> -EARLY_PCI_OP(write, byte, u8)
> -EARLY_PCI_OP(write, word, u16)
> -EARLY_PCI_OP(write, dword, u32)
> -
> -int __init pci_is_66mhz_capable(struct pci_channel *hose,
> - int top_bus, int current_bus)
> -{
> - u32 pci_devfn;
> - unsigned short vid;
> - int cap66 = -1;
> - u16 stat;
> -
> - printk(KERN_INFO "PCI: Checking 66MHz capabilities...\n");
> -
> - for (pci_devfn = 0; pci_devfn < 0xff; pci_devfn++) {
> - if (PCI_FUNC(pci_devfn))
> - continue;
> - if (early_read_config_word(hose, top_bus, current_bus,
> -pci_devfn, PCI_VENDOR_ID, ) !=
> - PCIBIOS_SUCCESSFUL)
> - continue;
> - if (vid == 0x)
> - continue;
> -
> - /* check 66MHz capability */
> - if (cap66 < 0)
> - cap66 = 1;
> - if (cap66) {
> - early_read_config_word(hose, top_bus, current_bus,
> -pci_devfn, PCI_STATUS, );
> - if (!(stat & PCI_STATUS_66MHZ)) {
> - printk(KERN_DEBUG
> -"PCI: %02x:%02x not 66MHz capable.\n",
> -current_bus, pci_devfn);
> - cap66 = 0;
> - break;
> - }
> - }
> - }
> -
> - return cap66 > 0;
> -}
> -
> -static void pcibios_enable_err(unsigned long __data)
> -{
> - struct pci_channel *hose = (struct pci_channel *)__data;
> -
> - del_timer(>err_timer);
> - printk(KERN_DEBUG "PCI: re-enabling error IRQ.\n");
> - enable_irq(hose->err_irq);
> -}
> -
> -static void pcibios_enable_serr(unsigned long __data)
> -{
> - struct pci_channel *hose = (struct pci_channel *)__data;
> -
> - del_timer(>serr_timer);
> - printk(KERN_DEBUG "PCI: re-enabling system error IRQ.\n");
> - enable_irq(hose->serr_irq);
> -}
> -
> -void 

Re: [PATCH v5 15/22] sh: Move common PCI stuff to arch/sh/kernel

2016-07-03 Thread Rich Felker
On Mon, Jul 04, 2016 at 01:46:35AM +0900, Yoshinori Sato wrote:
> Signed-off-by: Yoshinori Sato 
> ---
>  arch/sh/drivers/pci/Makefile |   2 -
>  arch/sh/drivers/pci/common.c | 162 
>  arch/sh/drivers/pci/pci.c| 320 
>  arch/sh/kernel/Makefile  |   2 +
>  arch/sh/kernel/pci-common.c  | 162 
>  arch/sh/kernel/pci.c | 342 
> +++
>  6 files changed, 506 insertions(+), 484 deletions(-)
>  delete mode 100644 arch/sh/drivers/pci/common.c
>  delete mode 100644 arch/sh/drivers/pci/pci.c
>  create mode 100644 arch/sh/kernel/pci-common.c
>  create mode 100644 arch/sh/kernel/pci.c
> 
> diff --git a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile
> index 82f0a33..fffbede 100644
> --- a/arch/sh/drivers/pci/Makefile
> +++ b/arch/sh/drivers/pci/Makefile
> @@ -1,8 +1,6 @@
>  #
>  # Makefile for the PCI specific kernel interface routines under Linux.
>  #
> -obj-y+= common.o pci.o
> -
>  obj-$(CONFIG_CPU_SUBTYPE_SH7751) += pci-sh7751.o ops-sh4.o
>  obj-$(CONFIG_CPU_SUBTYPE_SH7751R)+= pci-sh7751.o ops-sh4.o
>  obj-$(CONFIG_CPU_SUBTYPE_SH7763) += pci-sh7780.o ops-sh4.o
> diff --git a/arch/sh/drivers/pci/common.c b/arch/sh/drivers/pci/common.c
> deleted file mode 100644
> index dbf1381..000
> --- a/arch/sh/drivers/pci/common.c
> +++ /dev/null
> @@ -1,162 +0,0 @@
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -/*
> - * These functions are used early on before PCI scanning is done
> - * and all of the pci_dev and pci_bus structures have been created.
> - */
> -static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
> - int top_bus, int busnr, int devfn)
> -{
> - static struct pci_dev dev;
> - static struct pci_bus bus;
> -
> - dev.bus = 
> - dev.sysdata = hose;
> - dev.devfn = devfn;
> - bus.number = busnr;
> - bus.sysdata = hose;
> - bus.ops = hose->pci_ops;
> -
> - if(busnr != top_bus)
> - /* Fake a parent bus structure. */
> - bus.parent = 
> - else
> - bus.parent = NULL;
> -
> - return 
> -}
> -
> -#define EARLY_PCI_OP(rw, size, type) \
> -int __init early_##rw##_config_##size(struct pci_channel *hose,  
> \
> - int top_bus, int bus, int devfn, int offset, type value)\
> -{\
> - return pci_##rw##_config_##size(\
> - fake_pci_dev(hose, top_bus, bus, devfn),\
> - offset, value); \
> -}
> -
> -EARLY_PCI_OP(read, byte, u8 *)
> -EARLY_PCI_OP(read, word, u16 *)
> -EARLY_PCI_OP(read, dword, u32 *)
> -EARLY_PCI_OP(write, byte, u8)
> -EARLY_PCI_OP(write, word, u16)
> -EARLY_PCI_OP(write, dword, u32)
> -
> -int __init pci_is_66mhz_capable(struct pci_channel *hose,
> - int top_bus, int current_bus)
> -{
> - u32 pci_devfn;
> - unsigned short vid;
> - int cap66 = -1;
> - u16 stat;
> -
> - printk(KERN_INFO "PCI: Checking 66MHz capabilities...\n");
> -
> - for (pci_devfn = 0; pci_devfn < 0xff; pci_devfn++) {
> - if (PCI_FUNC(pci_devfn))
> - continue;
> - if (early_read_config_word(hose, top_bus, current_bus,
> -pci_devfn, PCI_VENDOR_ID, ) !=
> - PCIBIOS_SUCCESSFUL)
> - continue;
> - if (vid == 0x)
> - continue;
> -
> - /* check 66MHz capability */
> - if (cap66 < 0)
> - cap66 = 1;
> - if (cap66) {
> - early_read_config_word(hose, top_bus, current_bus,
> -pci_devfn, PCI_STATUS, );
> - if (!(stat & PCI_STATUS_66MHZ)) {
> - printk(KERN_DEBUG
> -"PCI: %02x:%02x not 66MHz capable.\n",
> -current_bus, pci_devfn);
> - cap66 = 0;
> - break;
> - }
> - }
> - }
> -
> - return cap66 > 0;
> -}
> -
> -static void pcibios_enable_err(unsigned long __data)
> -{
> - struct pci_channel *hose = (struct pci_channel *)__data;
> -
> - del_timer(>err_timer);
> - printk(KERN_DEBUG "PCI: re-enabling error IRQ.\n");
> - enable_irq(hose->err_irq);
> -}
> -
> -static void pcibios_enable_serr(unsigned long __data)
> -{
> - struct pci_channel *hose = (struct pci_channel *)__data;
> -
> - del_timer(>serr_timer);
> - printk(KERN_DEBUG "PCI: re-enabling system error IRQ.\n");
> - enable_irq(hose->serr_irq);
> -}
> -
> -void pcibios_enable_timers(struct pci_channel *hose)

[PATCH v5 15/22] sh: Move common PCI stuff to arch/sh/kernel

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/sh/drivers/pci/Makefile |   2 -
 arch/sh/drivers/pci/common.c | 162 
 arch/sh/drivers/pci/pci.c| 320 
 arch/sh/kernel/Makefile  |   2 +
 arch/sh/kernel/pci-common.c  | 162 
 arch/sh/kernel/pci.c | 342 +++
 6 files changed, 506 insertions(+), 484 deletions(-)
 delete mode 100644 arch/sh/drivers/pci/common.c
 delete mode 100644 arch/sh/drivers/pci/pci.c
 create mode 100644 arch/sh/kernel/pci-common.c
 create mode 100644 arch/sh/kernel/pci.c

diff --git a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile
index 82f0a33..fffbede 100644
--- a/arch/sh/drivers/pci/Makefile
+++ b/arch/sh/drivers/pci/Makefile
@@ -1,8 +1,6 @@
 #
 # Makefile for the PCI specific kernel interface routines under Linux.
 #
-obj-y  += common.o pci.o
-
 obj-$(CONFIG_CPU_SUBTYPE_SH7751)   += pci-sh7751.o ops-sh4.o
 obj-$(CONFIG_CPU_SUBTYPE_SH7751R)  += pci-sh7751.o ops-sh4.o
 obj-$(CONFIG_CPU_SUBTYPE_SH7763)   += pci-sh7780.o ops-sh4.o
diff --git a/arch/sh/drivers/pci/common.c b/arch/sh/drivers/pci/common.c
deleted file mode 100644
index dbf1381..000
--- a/arch/sh/drivers/pci/common.c
+++ /dev/null
@@ -1,162 +0,0 @@
-#include 
-#include 
-#include 
-#include 
-
-/*
- * These functions are used early on before PCI scanning is done
- * and all of the pci_dev and pci_bus structures have been created.
- */
-static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
-   int top_bus, int busnr, int devfn)
-{
-   static struct pci_dev dev;
-   static struct pci_bus bus;
-
-   dev.bus = 
-   dev.sysdata = hose;
-   dev.devfn = devfn;
-   bus.number = busnr;
-   bus.sysdata = hose;
-   bus.ops = hose->pci_ops;
-
-   if(busnr != top_bus)
-   /* Fake a parent bus structure. */
-   bus.parent = 
-   else
-   bus.parent = NULL;
-
-   return 
-}
-
-#define EARLY_PCI_OP(rw, size, type)   \
-int __init early_##rw##_config_##size(struct pci_channel *hose,
\
-   int top_bus, int bus, int devfn, int offset, type value)\
-{  \
-   return pci_##rw##_config_##size(\
-   fake_pci_dev(hose, top_bus, bus, devfn),\
-   offset, value); \
-}
-
-EARLY_PCI_OP(read, byte, u8 *)
-EARLY_PCI_OP(read, word, u16 *)
-EARLY_PCI_OP(read, dword, u32 *)
-EARLY_PCI_OP(write, byte, u8)
-EARLY_PCI_OP(write, word, u16)
-EARLY_PCI_OP(write, dword, u32)
-
-int __init pci_is_66mhz_capable(struct pci_channel *hose,
-   int top_bus, int current_bus)
-{
-   u32 pci_devfn;
-   unsigned short vid;
-   int cap66 = -1;
-   u16 stat;
-
-   printk(KERN_INFO "PCI: Checking 66MHz capabilities...\n");
-
-   for (pci_devfn = 0; pci_devfn < 0xff; pci_devfn++) {
-   if (PCI_FUNC(pci_devfn))
-   continue;
-   if (early_read_config_word(hose, top_bus, current_bus,
-  pci_devfn, PCI_VENDOR_ID, ) !=
-   PCIBIOS_SUCCESSFUL)
-   continue;
-   if (vid == 0x)
-   continue;
-
-   /* check 66MHz capability */
-   if (cap66 < 0)
-   cap66 = 1;
-   if (cap66) {
-   early_read_config_word(hose, top_bus, current_bus,
-  pci_devfn, PCI_STATUS, );
-   if (!(stat & PCI_STATUS_66MHZ)) {
-   printk(KERN_DEBUG
-  "PCI: %02x:%02x not 66MHz capable.\n",
-  current_bus, pci_devfn);
-   cap66 = 0;
-   break;
-   }
-   }
-   }
-
-   return cap66 > 0;
-}
-
-static void pcibios_enable_err(unsigned long __data)
-{
-   struct pci_channel *hose = (struct pci_channel *)__data;
-
-   del_timer(>err_timer);
-   printk(KERN_DEBUG "PCI: re-enabling error IRQ.\n");
-   enable_irq(hose->err_irq);
-}
-
-static void pcibios_enable_serr(unsigned long __data)
-{
-   struct pci_channel *hose = (struct pci_channel *)__data;
-
-   del_timer(>serr_timer);
-   printk(KERN_DEBUG "PCI: re-enabling system error IRQ.\n");
-   enable_irq(hose->serr_irq);
-}
-
-void pcibios_enable_timers(struct pci_channel *hose)
-{
-   if (hose->err_irq) {
-   init_timer(>err_timer);
-   hose->err_timer.data = (unsigned long)hose;
-   hose->err_timer.function = pcibios_enable_err;

[PATCH v5 15/22] sh: Move common PCI stuff to arch/sh/kernel

2016-07-03 Thread Yoshinori Sato
Signed-off-by: Yoshinori Sato 
---
 arch/sh/drivers/pci/Makefile |   2 -
 arch/sh/drivers/pci/common.c | 162 
 arch/sh/drivers/pci/pci.c| 320 
 arch/sh/kernel/Makefile  |   2 +
 arch/sh/kernel/pci-common.c  | 162 
 arch/sh/kernel/pci.c | 342 +++
 6 files changed, 506 insertions(+), 484 deletions(-)
 delete mode 100644 arch/sh/drivers/pci/common.c
 delete mode 100644 arch/sh/drivers/pci/pci.c
 create mode 100644 arch/sh/kernel/pci-common.c
 create mode 100644 arch/sh/kernel/pci.c

diff --git a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile
index 82f0a33..fffbede 100644
--- a/arch/sh/drivers/pci/Makefile
+++ b/arch/sh/drivers/pci/Makefile
@@ -1,8 +1,6 @@
 #
 # Makefile for the PCI specific kernel interface routines under Linux.
 #
-obj-y  += common.o pci.o
-
 obj-$(CONFIG_CPU_SUBTYPE_SH7751)   += pci-sh7751.o ops-sh4.o
 obj-$(CONFIG_CPU_SUBTYPE_SH7751R)  += pci-sh7751.o ops-sh4.o
 obj-$(CONFIG_CPU_SUBTYPE_SH7763)   += pci-sh7780.o ops-sh4.o
diff --git a/arch/sh/drivers/pci/common.c b/arch/sh/drivers/pci/common.c
deleted file mode 100644
index dbf1381..000
--- a/arch/sh/drivers/pci/common.c
+++ /dev/null
@@ -1,162 +0,0 @@
-#include 
-#include 
-#include 
-#include 
-
-/*
- * These functions are used early on before PCI scanning is done
- * and all of the pci_dev and pci_bus structures have been created.
- */
-static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
-   int top_bus, int busnr, int devfn)
-{
-   static struct pci_dev dev;
-   static struct pci_bus bus;
-
-   dev.bus = 
-   dev.sysdata = hose;
-   dev.devfn = devfn;
-   bus.number = busnr;
-   bus.sysdata = hose;
-   bus.ops = hose->pci_ops;
-
-   if(busnr != top_bus)
-   /* Fake a parent bus structure. */
-   bus.parent = 
-   else
-   bus.parent = NULL;
-
-   return 
-}
-
-#define EARLY_PCI_OP(rw, size, type)   \
-int __init early_##rw##_config_##size(struct pci_channel *hose,
\
-   int top_bus, int bus, int devfn, int offset, type value)\
-{  \
-   return pci_##rw##_config_##size(\
-   fake_pci_dev(hose, top_bus, bus, devfn),\
-   offset, value); \
-}
-
-EARLY_PCI_OP(read, byte, u8 *)
-EARLY_PCI_OP(read, word, u16 *)
-EARLY_PCI_OP(read, dword, u32 *)
-EARLY_PCI_OP(write, byte, u8)
-EARLY_PCI_OP(write, word, u16)
-EARLY_PCI_OP(write, dword, u32)
-
-int __init pci_is_66mhz_capable(struct pci_channel *hose,
-   int top_bus, int current_bus)
-{
-   u32 pci_devfn;
-   unsigned short vid;
-   int cap66 = -1;
-   u16 stat;
-
-   printk(KERN_INFO "PCI: Checking 66MHz capabilities...\n");
-
-   for (pci_devfn = 0; pci_devfn < 0xff; pci_devfn++) {
-   if (PCI_FUNC(pci_devfn))
-   continue;
-   if (early_read_config_word(hose, top_bus, current_bus,
-  pci_devfn, PCI_VENDOR_ID, ) !=
-   PCIBIOS_SUCCESSFUL)
-   continue;
-   if (vid == 0x)
-   continue;
-
-   /* check 66MHz capability */
-   if (cap66 < 0)
-   cap66 = 1;
-   if (cap66) {
-   early_read_config_word(hose, top_bus, current_bus,
-  pci_devfn, PCI_STATUS, );
-   if (!(stat & PCI_STATUS_66MHZ)) {
-   printk(KERN_DEBUG
-  "PCI: %02x:%02x not 66MHz capable.\n",
-  current_bus, pci_devfn);
-   cap66 = 0;
-   break;
-   }
-   }
-   }
-
-   return cap66 > 0;
-}
-
-static void pcibios_enable_err(unsigned long __data)
-{
-   struct pci_channel *hose = (struct pci_channel *)__data;
-
-   del_timer(>err_timer);
-   printk(KERN_DEBUG "PCI: re-enabling error IRQ.\n");
-   enable_irq(hose->err_irq);
-}
-
-static void pcibios_enable_serr(unsigned long __data)
-{
-   struct pci_channel *hose = (struct pci_channel *)__data;
-
-   del_timer(>serr_timer);
-   printk(KERN_DEBUG "PCI: re-enabling system error IRQ.\n");
-   enable_irq(hose->serr_irq);
-}
-
-void pcibios_enable_timers(struct pci_channel *hose)
-{
-   if (hose->err_irq) {
-   init_timer(>err_timer);
-   hose->err_timer.data = (unsigned long)hose;
-   hose->err_timer.function = pcibios_enable_err;
-   }
-
-   if