Skip to content

Commit 1da09c4

Browse files
committed
sh: pci: Support asynchronous initialization of SH-X3 PCIe channels.
SH-X3 controllers all have pretty dire delays needed for PHY wakeup, so we attempt to mitigate the damage by bringing them up asynchronously, simply using the synchronization points for persistent bridge to channel numbering. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent e6f597a commit 1da09c4

1 file changed

Lines changed: 28 additions & 18 deletions

File tree

‎arch/sh/drivers/pci/pcie-sh7786.c‎

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
/*
22
* Low-Level PCI Express Support for the SH7786
33
*
4-
* Copyright (C) 2009 - 2010 Paul Mundt
4+
* Copyright (C) 2009 - 2011 Paul Mundt
55
*
66
* This file is subject to the terms and conditions of the GNU General Public
77
* License. See the file "COPYING" in the main directory of this archive
88
* for more details.
99
*/
10+
#define pr_fmt(fmt) "PCI: " fmt
11+
1012
#include <linux/pci.h>
1113
#include <linux/init.h>
1214
#include <linux/kernel.h>
1315
#include <linux/io.h>
16+
#include <linux/async.h>
1417
#include <linux/delay.h>
1518
#include <linux/slab.h>
1619
#include <linux/clk.h>
@@ -31,7 +34,7 @@ static unsigned int nr_ports;
3134

3235
static struct sh7786_pcie_hwops {
3336
int (*core_init)(void);
34-
int (*port_init_hw)(struct sh7786_pcie_port *port);
37+
async_func_ptr *port_init_hw;
3538
} *sh7786_pcie_hwops;
3639

3740
static struct resource sh7786_pci0_resources[] = {
@@ -474,8 +477,9 @@ static int __init sh7786_pcie_core_init(void)
474477
return test_mode_pin(MODE_PIN12) ? 3 : 2;
475478
}
476479

477-
static int __init sh7786_pcie_init_hw(struct sh7786_pcie_port *port)
480+
static void __init sh7786_pcie_init_hw(void *data, async_cookie_t cookie)
478481
{
482+
struct sh7786_pcie_port *port = data;
479483
int ret;
480484

481485
/*
@@ -488,18 +492,30 @@ static int __init sh7786_pcie_init_hw(struct sh7786_pcie_port *port)
488492
* Setup clocks, needed both for PHY and PCIe registers.
489493
*/
490494
ret = pcie_clk_init(port);
491-
if (unlikely(ret < 0))
492-
return ret;
495+
if (unlikely(ret < 0)) {
496+
pr_err("clock initialization failed for port#%d\n",
497+
port->index);
498+
return;
499+
}
493500

494501
ret = phy_init(port);
495-
if (unlikely(ret < 0))
496-
return ret;
502+
if (unlikely(ret < 0)) {
503+
pr_err("phy initialization failed for port#%d\n",
504+
port->index);
505+
return;
506+
}
497507

498508
ret = pcie_init(port);
499-
if (unlikely(ret < 0))
500-
return ret;
509+
if (unlikely(ret < 0)) {
510+
pr_err("core initialization failed for port#%d\n",
511+
port->index);
512+
return;
513+
}
501514

502-
return register_pci_controller(port->hose);
515+
/* In the interest of preserving device ordering, synchronize */
516+
async_synchronize_cookie(cookie);
517+
518+
register_pci_controller(port->hose);
503519
}
504520

505521
static struct sh7786_pcie_hwops sh7786_65nm_pcie_hwops __initdata = {
@@ -510,7 +526,7 @@ static struct sh7786_pcie_hwops sh7786_65nm_pcie_hwops __initdata = {
510526
static int __init sh7786_pcie_init(void)
511527
{
512528
struct clk *platclk;
513-
int ret = 0, i;
529+
int i;
514530

515531
printk(KERN_NOTICE "PCI: Starting initialization.\n");
516532

@@ -552,13 +568,7 @@ static int __init sh7786_pcie_init(void)
552568
port->hose = sh7786_pci_channels + i;
553569
port->hose->io_map_base = port->hose->resources[0].start;
554570

555-
ret |= sh7786_pcie_hwops->port_init_hw(port);
556-
}
557-
558-
if (unlikely(ret)) {
559-
clk_disable(platclk);
560-
clk_put(platclk);
561-
return ret;
571+
async_schedule(sh7786_pcie_hwops->port_init_hw, port);
562572
}
563573

564574
return 0;

0 commit comments

Comments
 (0)