提交 152d0182 编写于 作者: K Kumar Gala

powerpc/85xx: Add SWIOTLB support to FSL boards

Add the platform-specific code for enabling SWIOTLB if needed on P2020DS,
MPC85xx DS, and MPC85xx MDS boards as they are capable of having >4G of
memory.

We determine if we need to enable swiotlb based on how much memory is in
the board and if it exceeds 4G or what we can map via PCI inbound
windows.
Signed-off-by: NKumar Gala <galak@kernel.crashing.org>
上级 5cef379b
...@@ -35,12 +35,14 @@ config MPC85xx_MDS ...@@ -35,12 +35,14 @@ config MPC85xx_MDS
select DEFAULT_UIMAGE select DEFAULT_UIMAGE
select PHYLIB select PHYLIB
select HAS_RAPIDIO select HAS_RAPIDIO
select SWIOTLB
help help
This option enables support for the MPC85xx MDS board This option enables support for the MPC85xx MDS board
config MPC8536_DS config MPC8536_DS
bool "Freescale MPC8536 DS" bool "Freescale MPC8536 DS"
select DEFAULT_UIMAGE select DEFAULT_UIMAGE
select SWIOTLB
help help
This option enables support for the MPC8536 DS board This option enables support for the MPC8536 DS board
...@@ -49,6 +51,7 @@ config MPC85xx_DS ...@@ -49,6 +51,7 @@ config MPC85xx_DS
select PPC_I8259 select PPC_I8259
select DEFAULT_UIMAGE select DEFAULT_UIMAGE
select FSL_ULI1575 select FSL_ULI1575
select SWIOTLB
help help
This option enables support for the MPC85xx DS (MPC8544 DS) board This option enables support for the MPC85xx DS (MPC8544 DS) board
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/lmb.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/time.h> #include <asm/time.h>
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/udbg.h> #include <asm/udbg.h>
#include <asm/mpic.h> #include <asm/mpic.h>
#include <asm/swiotlb.h>
#include <sysdev/fsl_soc.h> #include <sysdev/fsl_soc.h>
#include <sysdev/fsl_pci.h> #include <sysdev/fsl_pci.h>
...@@ -65,7 +67,9 @@ static void __init mpc8536_ds_setup_arch(void) ...@@ -65,7 +67,9 @@ static void __init mpc8536_ds_setup_arch(void)
{ {
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
struct device_node *np; struct device_node *np;
struct pci_controller *hose;
#endif #endif
dma_addr_t max = 0xffffffff;
if (ppc_md.progress) if (ppc_md.progress)
ppc_md.progress("mpc8536_ds_setup_arch()", 0); ppc_md.progress("mpc8536_ds_setup_arch()", 0);
...@@ -80,11 +84,22 @@ static void __init mpc8536_ds_setup_arch(void) ...@@ -80,11 +84,22 @@ static void __init mpc8536_ds_setup_arch(void)
fsl_add_bridge(np, 1); fsl_add_bridge(np, 1);
else else
fsl_add_bridge(np, 0); fsl_add_bridge(np, 0);
hose = pci_find_hose_for_OF_device(np);
max = min(max, hose->dma_window_base_cur +
hose->dma_window_size);
} }
} }
#endif #endif
#ifdef CONFIG_SWIOTLB
if (lmb_end_of_DRAM() > max) {
ppc_swiotlb_enable = 1;
set_pci_dma_ops(&swiotlb_pci_dma_ops);
}
#endif
printk("MPC8536 DS board from Freescale Semiconductor\n"); printk("MPC8536 DS board from Freescale Semiconductor\n");
} }
...@@ -102,6 +117,8 @@ static int __init mpc8536_ds_publish_devices(void) ...@@ -102,6 +117,8 @@ static int __init mpc8536_ds_publish_devices(void)
} }
machine_device_initcall(mpc8536_ds, mpc8536_ds_publish_devices); machine_device_initcall(mpc8536_ds, mpc8536_ds_publish_devices);
machine_arch_initcall(mpc8536_ds, swiotlb_setup_bus_notifier);
/* /*
* Called very early, device-tree isn't unflattened * Called very early, device-tree isn't unflattened
*/ */
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/lmb.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/time.h> #include <asm/time.h>
...@@ -30,6 +31,7 @@ ...@@ -30,6 +31,7 @@
#include <asm/udbg.h> #include <asm/udbg.h>
#include <asm/mpic.h> #include <asm/mpic.h>
#include <asm/i8259.h> #include <asm/i8259.h>
#include <asm/swiotlb.h>
#include <sysdev/fsl_soc.h> #include <sysdev/fsl_soc.h>
#include <sysdev/fsl_pci.h> #include <sysdev/fsl_pci.h>
...@@ -155,7 +157,9 @@ static void __init mpc85xx_ds_setup_arch(void) ...@@ -155,7 +157,9 @@ static void __init mpc85xx_ds_setup_arch(void)
{ {
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
struct device_node *np; struct device_node *np;
struct pci_controller *hose;
#endif #endif
dma_addr_t max = 0xffffffff;
if (ppc_md.progress) if (ppc_md.progress)
ppc_md.progress("mpc85xx_ds_setup_arch()", 0); ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
...@@ -171,6 +175,10 @@ static void __init mpc85xx_ds_setup_arch(void) ...@@ -171,6 +175,10 @@ static void __init mpc85xx_ds_setup_arch(void)
fsl_add_bridge(np, 1); fsl_add_bridge(np, 1);
else else
fsl_add_bridge(np, 0); fsl_add_bridge(np, 0);
hose = pci_find_hose_for_OF_device(np);
max = min(max, hose->dma_window_base_cur +
hose->dma_window_size);
} }
} }
...@@ -181,6 +189,13 @@ static void __init mpc85xx_ds_setup_arch(void) ...@@ -181,6 +189,13 @@ static void __init mpc85xx_ds_setup_arch(void)
mpc85xx_smp_init(); mpc85xx_smp_init();
#endif #endif
#ifdef CONFIG_SWIOTLB
if (lmb_end_of_DRAM() > max) {
ppc_swiotlb_enable = 1;
set_pci_dma_ops(&swiotlb_pci_dma_ops);
}
#endif
printk("MPC85xx DS board from Freescale Semiconductor\n"); printk("MPC85xx DS board from Freescale Semiconductor\n");
} }
...@@ -217,6 +232,10 @@ machine_device_initcall(mpc8544_ds, mpc85xxds_publish_devices); ...@@ -217,6 +232,10 @@ machine_device_initcall(mpc8544_ds, mpc85xxds_publish_devices);
machine_device_initcall(mpc8572_ds, mpc85xxds_publish_devices); machine_device_initcall(mpc8572_ds, mpc85xxds_publish_devices);
machine_device_initcall(p2020_ds, mpc85xxds_publish_devices); machine_device_initcall(p2020_ds, mpc85xxds_publish_devices);
machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier);
machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier);
machine_arch_initcall(p2020_ds, swiotlb_setup_bus_notifier);
/* /*
* Called very early, device-tree isn't unflattened * Called very early, device-tree isn't unflattened
*/ */
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/lmb.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/atomic.h> #include <asm/atomic.h>
...@@ -49,6 +50,7 @@ ...@@ -49,6 +50,7 @@
#include <asm/qe.h> #include <asm/qe.h>
#include <asm/qe_ic.h> #include <asm/qe_ic.h>
#include <asm/mpic.h> #include <asm/mpic.h>
#include <asm/swiotlb.h>
#undef DEBUG #undef DEBUG
#ifdef DEBUG #ifdef DEBUG
...@@ -155,6 +157,10 @@ static void __init mpc85xx_mds_setup_arch(void) ...@@ -155,6 +157,10 @@ static void __init mpc85xx_mds_setup_arch(void)
{ {
struct device_node *np; struct device_node *np;
static u8 __iomem *bcsr_regs = NULL; static u8 __iomem *bcsr_regs = NULL;
#ifdef CONFIG_PCI
struct pci_controller *hose;
#endif
dma_addr_t max = 0xffffffff;
if (ppc_md.progress) if (ppc_md.progress)
ppc_md.progress("mpc85xx_mds_setup_arch()", 0); ppc_md.progress("mpc85xx_mds_setup_arch()", 0);
...@@ -179,6 +185,10 @@ static void __init mpc85xx_mds_setup_arch(void) ...@@ -179,6 +185,10 @@ static void __init mpc85xx_mds_setup_arch(void)
fsl_add_bridge(np, 1); fsl_add_bridge(np, 1);
else else
fsl_add_bridge(np, 0); fsl_add_bridge(np, 0);
hose = pci_find_hose_for_OF_device(np);
max = min(max, hose->dma_window_base_cur +
hose->dma_window_size);
} }
} }
#endif #endif
...@@ -227,6 +237,13 @@ static void __init mpc85xx_mds_setup_arch(void) ...@@ -227,6 +237,13 @@ static void __init mpc85xx_mds_setup_arch(void)
iounmap(bcsr_regs); iounmap(bcsr_regs);
} }
#endif /* CONFIG_QUICC_ENGINE */ #endif /* CONFIG_QUICC_ENGINE */
#ifdef CONFIG_SWIOTLB
if (lmb_end_of_DRAM() > max) {
ppc_swiotlb_enable = 1;
set_pci_dma_ops(&swiotlb_pci_dma_ops);
}
#endif
} }
...@@ -281,6 +298,9 @@ static int __init mpc85xx_publish_devices(void) ...@@ -281,6 +298,9 @@ static int __init mpc85xx_publish_devices(void)
machine_device_initcall(mpc8568_mds, mpc85xx_publish_devices); machine_device_initcall(mpc8568_mds, mpc85xx_publish_devices);
machine_device_initcall(mpc8569_mds, mpc85xx_publish_devices); machine_device_initcall(mpc8569_mds, mpc85xx_publish_devices);
machine_arch_initcall(mpc8568_mds, swiotlb_setup_bus_notifier);
machine_arch_initcall(mpc8569_mds, swiotlb_setup_bus_notifier);
static void __init mpc85xx_mds_pic_init(void) static void __init mpc85xx_mds_pic_init(void)
{ {
struct mpic *mpic; struct mpic *mpic;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册