diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-s5pv310/include/mach/irqs.h | 18 | ||||
-rw-r--r-- | arch/arm/mach-s5pv310/include/mach/map.h | 19 | ||||
-rw-r--r-- | arch/arm/mach-s5pv310/include/mach/regs-sysmmu.h | 24 | ||||
-rw-r--r-- | arch/arm/mach-s5pv310/include/mach/sysmmu.h | 119 | ||||
-rw-r--r-- | arch/arm/plat-s5p/Kconfig | 16 | ||||
-rw-r--r-- | arch/arm/plat-s5p/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/plat-s5p/include/plat/sysmmu.h | 23 | ||||
-rw-r--r-- | arch/arm/plat-s5p/sysmmu.c | 328 |
8 files changed, 548 insertions, 0 deletions
diff --git a/arch/arm/mach-s5pv310/include/mach/irqs.h b/arch/arm/mach-s5pv310/include/mach/irqs.h index 1dd130a34782..536b0b59fc83 100644 --- a/arch/arm/mach-s5pv310/include/mach/irqs.h +++ b/arch/arm/mach-s5pv310/include/mach/irqs.h | |||
@@ -55,6 +55,24 @@ | |||
55 | #define COMBINER_GROUP(x) ((x) * MAX_IRQ_IN_COMBINER + IRQ_SPI(64)) | 55 | #define COMBINER_GROUP(x) ((x) * MAX_IRQ_IN_COMBINER + IRQ_SPI(64)) |
56 | #define COMBINER_IRQ(x, y) (COMBINER_GROUP(x) + y) | 56 | #define COMBINER_IRQ(x, y) (COMBINER_GROUP(x) + y) |
57 | 57 | ||
58 | #define IRQ_SYSMMU_MDMA0_0 COMBINER_IRQ(4, 0) | ||
59 | #define IRQ_SYSMMU_SSS_0 COMBINER_IRQ(4, 1) | ||
60 | #define IRQ_SYSMMU_FIMC0_0 COMBINER_IRQ(4, 2) | ||
61 | #define IRQ_SYSMMU_FIMC1_0 COMBINER_IRQ(4, 3) | ||
62 | #define IRQ_SYSMMU_FIMC2_0 COMBINER_IRQ(4, 4) | ||
63 | #define IRQ_SYSMMU_FIMC3_0 COMBINER_IRQ(4, 5) | ||
64 | #define IRQ_SYSMMU_JPEG_0 COMBINER_IRQ(4, 6) | ||
65 | #define IRQ_SYSMMU_2D_0 COMBINER_IRQ(4, 7) | ||
66 | |||
67 | #define IRQ_SYSMMU_ROTATOR_0 COMBINER_IRQ(5, 0) | ||
68 | #define IRQ_SYSMMU_MDMA1_0 COMBINER_IRQ(5, 1) | ||
69 | #define IRQ_SYSMMU_LCD0_M0_0 COMBINER_IRQ(5, 2) | ||
70 | #define IRQ_SYSMMU_LCD1_M1_0 COMBINER_IRQ(5, 3) | ||
71 | #define IRQ_SYSMMU_TV_M0_0 COMBINER_IRQ(5, 4) | ||
72 | #define IRQ_SYSMMU_MFC_M0_0 COMBINER_IRQ(5, 5) | ||
73 | #define IRQ_SYSMMU_MFC_M1_0 COMBINER_IRQ(5, 6) | ||
74 | #define IRQ_SYSMMU_PCIE_0 COMBINER_IRQ(5, 7) | ||
75 | |||
58 | #define IRQ_PDMA0 COMBINER_IRQ(21, 0) | 76 | #define IRQ_PDMA0 COMBINER_IRQ(21, 0) |
59 | #define IRQ_PDMA1 COMBINER_IRQ(21, 1) | 77 | #define IRQ_PDMA1 COMBINER_IRQ(21, 1) |
60 | 78 | ||
diff --git a/arch/arm/mach-s5pv310/include/mach/map.h b/arch/arm/mach-s5pv310/include/mach/map.h index 33bcff2a9568..74d400625a23 100644 --- a/arch/arm/mach-s5pv310/include/mach/map.h +++ b/arch/arm/mach-s5pv310/include/mach/map.h | |||
@@ -108,6 +108,25 @@ | |||
108 | #define S5PV310_PA_SDRAM (0x40000000) | 108 | #define S5PV310_PA_SDRAM (0x40000000) |
109 | #define S5P_PA_SDRAM S5PV310_PA_SDRAM | 109 | #define S5P_PA_SDRAM S5PV310_PA_SDRAM |
110 | 110 | ||
111 | #define S5PV310_PA_SYSMMU_MDMA 0x10A40000 | ||
112 | #define S5PV310_PA_SYSMMU_SSS 0x10A50000 | ||
113 | #define S5PV310_PA_SYSMMU_FIMC0 0x11A20000 | ||
114 | #define S5PV310_PA_SYSMMU_FIMC1 0x11A30000 | ||
115 | #define S5PV310_PA_SYSMMU_FIMC2 0x11A40000 | ||
116 | #define S5PV310_PA_SYSMMU_FIMC3 0x11A50000 | ||
117 | #define S5PV310_PA_SYSMMU_JPEG 0x11A60000 | ||
118 | #define S5PV310_PA_SYSMMU_FIMD0 0x11E20000 | ||
119 | #define S5PV310_PA_SYSMMU_FIMD1 0x12220000 | ||
120 | #define S5PV310_PA_SYSMMU_PCIe 0x12620000 | ||
121 | #define S5PV310_PA_SYSMMU_G2D 0x12A20000 | ||
122 | #define S5PV310_PA_SYSMMU_ROTATOR 0x12A30000 | ||
123 | #define S5PV310_PA_SYSMMU_MDMA2 0x12A40000 | ||
124 | #define S5PV310_PA_SYSMMU_TV 0x12E20000 | ||
125 | #define S5PV310_PA_SYSMMU_MFC_L 0x13620000 | ||
126 | #define S5PV310_PA_SYSMMU_MFC_R 0x13630000 | ||
127 | #define S5PV310_SYSMMU_TOTAL_IPNUM 16 | ||
128 | #define S5P_SYSMMU_TOTAL_IPNUM S5PV310_SYSMMU_TOTAL_IPNUM | ||
129 | |||
111 | /* compatibiltiy defines. */ | 130 | /* compatibiltiy defines. */ |
112 | #define S3C_PA_UART S5PV310_PA_UART | 131 | #define S3C_PA_UART S5PV310_PA_UART |
113 | #define S3C_PA_HSMMC0 S5PV310_PA_HSMMC(0) | 132 | #define S3C_PA_HSMMC0 S5PV310_PA_HSMMC(0) |
diff --git a/arch/arm/mach-s5pv310/include/mach/regs-sysmmu.h b/arch/arm/mach-s5pv310/include/mach/regs-sysmmu.h new file mode 100644 index 000000000000..0b28e81a16f7 --- /dev/null +++ b/arch/arm/mach-s5pv310/include/mach/regs-sysmmu.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* linux/arch/arm/mach-s5pv310/include/mach/regs-sysmmu.h | ||
2 | * | ||
3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | ||
5 | * | ||
6 | * S5PV310 - System MMU register | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #ifndef __ASM_ARCH_REGS_SYSMMU_H | ||
14 | #define __ASM_ARCH_REGS_SYSMMU_H __FILE__ | ||
15 | |||
16 | #define S5P_MMU_CTRL 0x000 | ||
17 | #define S5P_MMU_CFG 0x004 | ||
18 | #define S5P_MMU_STATUS 0x008 | ||
19 | #define S5P_MMU_FLUSH 0x00C | ||
20 | #define S5P_PT_BASE_ADDR 0x014 | ||
21 | #define S5P_INT_STATUS 0x018 | ||
22 | #define S5P_PAGE_FAULT_ADDR 0x024 | ||
23 | |||
24 | #endif /* __ASM_ARCH_REGS_SYSMMU_H */ | ||
diff --git a/arch/arm/mach-s5pv310/include/mach/sysmmu.h b/arch/arm/mach-s5pv310/include/mach/sysmmu.h new file mode 100644 index 000000000000..662fe85ff4d5 --- /dev/null +++ b/arch/arm/mach-s5pv310/include/mach/sysmmu.h | |||
@@ -0,0 +1,119 @@ | |||
1 | /* linux/arch/arm/mach-s5pv310/include/mach/sysmmu.h | ||
2 | * | ||
3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com/ | ||
5 | * | ||
6 | * Samsung sysmmu driver for S5PV310 | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #ifndef __ASM_ARM_ARCH_SYSMMU_H | ||
14 | #define __ASM_ARM_ARCH_SYSMMU_H __FILE__ | ||
15 | |||
16 | enum s5pv310_sysmmu_ips { | ||
17 | SYSMMU_MDMA, | ||
18 | SYSMMU_SSS, | ||
19 | SYSMMU_FIMC0, | ||
20 | SYSMMU_FIMC1, | ||
21 | SYSMMU_FIMC2, | ||
22 | SYSMMU_FIMC3, | ||
23 | SYSMMU_JPEG, | ||
24 | SYSMMU_FIMD0, | ||
25 | SYSMMU_FIMD1, | ||
26 | SYSMMU_PCIe, | ||
27 | SYSMMU_G2D, | ||
28 | SYSMMU_ROTATOR, | ||
29 | SYSMMU_MDMA2, | ||
30 | SYSMMU_TV, | ||
31 | SYSMMU_MFC_L, | ||
32 | SYSMMU_MFC_R, | ||
33 | }; | ||
34 | |||
35 | static char *sysmmu_ips_name[S5P_SYSMMU_TOTAL_IPNUM] = { | ||
36 | "SYSMMU_MDMA" , | ||
37 | "SYSMMU_SSS" , | ||
38 | "SYSMMU_FIMC0" , | ||
39 | "SYSMMU_FIMC1" , | ||
40 | "SYSMMU_FIMC2" , | ||
41 | "SYSMMU_FIMC3" , | ||
42 | "SYSMMU_JPEG" , | ||
43 | "SYSMMU_FIMD0" , | ||
44 | "SYSMMU_FIMD1" , | ||
45 | "SYSMMU_PCIe" , | ||
46 | "SYSMMU_G2D" , | ||
47 | "SYSMMU_ROTATOR", | ||
48 | "SYSMMU_MDMA2" , | ||
49 | "SYSMMU_TV" , | ||
50 | "SYSMMU_MFC_L" , | ||
51 | "SYSMMU_MFC_R" , | ||
52 | }; | ||
53 | |||
54 | typedef enum s5pv310_sysmmu_ips sysmmu_ips; | ||
55 | |||
56 | struct sysmmu_tt_info { | ||
57 | unsigned long *pgd; | ||
58 | unsigned long pgd_paddr; | ||
59 | unsigned long *pte; | ||
60 | }; | ||
61 | |||
62 | struct sysmmu_controller { | ||
63 | const char *name; | ||
64 | |||
65 | /* channels registers */ | ||
66 | void __iomem *regs; | ||
67 | |||
68 | /* channel irq */ | ||
69 | unsigned int irq; | ||
70 | |||
71 | sysmmu_ips ips; | ||
72 | |||
73 | /* Translation Table Info. */ | ||
74 | struct sysmmu_tt_info *tt_info; | ||
75 | |||
76 | struct resource *mem; | ||
77 | struct device *dev; | ||
78 | |||
79 | /* SysMMU controller enable - true : enable */ | ||
80 | bool enable; | ||
81 | }; | ||
82 | |||
83 | /** | ||
84 | * s5p_sysmmu_enable() - enable system mmu of ip | ||
85 | * @ips: The ip connected system mmu. | ||
86 | * | ||
87 | * This function enable system mmu to transfer address | ||
88 | * from virtual address to physical address | ||
89 | */ | ||
90 | int s5p_sysmmu_enable(sysmmu_ips ips); | ||
91 | |||
92 | /** | ||
93 | * s5p_sysmmu_disable() - disable sysmmu mmu of ip | ||
94 | * @ips: The ip connected system mmu. | ||
95 | * | ||
96 | * This function disable system mmu to transfer address | ||
97 | * from virtual address to physical address | ||
98 | */ | ||
99 | int s5p_sysmmu_disable(sysmmu_ips ips); | ||
100 | |||
101 | /** | ||
102 | * s5p_sysmmu_set_tablebase_pgd() - set page table base address to refer page table | ||
103 | * @ips: The ip connected system mmu. | ||
104 | * @pgd: The page table base address. | ||
105 | * | ||
106 | * This function set page table base address | ||
107 | * When system mmu transfer address from virtaul address to physical address, | ||
108 | * system mmu refer address information from page table | ||
109 | */ | ||
110 | int s5p_sysmmu_set_tablebase_pgd(sysmmu_ips ips, unsigned long pgd); | ||
111 | |||
112 | /** | ||
113 | * s5p_sysmmu_tlb_invalidate() - flush all TLB entry in system mmu | ||
114 | * @ips: The ip connected system mmu. | ||
115 | * | ||
116 | * This function flush all TLB entry in system mmu | ||
117 | */ | ||
118 | int s5p_sysmmu_tlb_invalidate(sysmmu_ips ips); | ||
119 | #endif /* __ASM_ARM_ARCH_SYSMMU_H */ | ||
diff --git a/arch/arm/plat-s5p/Kconfig b/arch/arm/plat-s5p/Kconfig index 6a161f317a79..deb39951a22e 100644 --- a/arch/arm/plat-s5p/Kconfig +++ b/arch/arm/plat-s5p/Kconfig | |||
@@ -66,3 +66,19 @@ config S5P_DEV_CSIS1 | |||
66 | bool | 66 | bool |
67 | help | 67 | help |
68 | Compile in platform device definitions for MIPI-CSIS channel 1 | 68 | Compile in platform device definitions for MIPI-CSIS channel 1 |
69 | |||
70 | menuconfig S5P_SYSMMU | ||
71 | bool "SYSMMU support" | ||
72 | depends on ARCH_S5PV310 | ||
73 | help | ||
74 | This is a System MMU driver for Samsung ARM based Soc. | ||
75 | |||
76 | if S5P_SYSMMU | ||
77 | |||
78 | config S5P_SYSMMU_DEBUG | ||
79 | bool "Enables debug messages" | ||
80 | depends on S5P_SYSMMU | ||
81 | help | ||
82 | This enables SYSMMU driver debug massages. | ||
83 | |||
84 | endif | ||
diff --git a/arch/arm/plat-s5p/Makefile b/arch/arm/plat-s5p/Makefile index 2b7317378103..92efe1adcfd6 100644 --- a/arch/arm/plat-s5p/Makefile +++ b/arch/arm/plat-s5p/Makefile | |||
@@ -30,3 +30,4 @@ obj-$(CONFIG_S5P_DEV_FIMC2) += dev-fimc2.o | |||
30 | obj-$(CONFIG_S5P_DEV_ONENAND) += dev-onenand.o | 30 | obj-$(CONFIG_S5P_DEV_ONENAND) += dev-onenand.o |
31 | obj-$(CONFIG_S5P_DEV_CSIS0) += dev-csis0.o | 31 | obj-$(CONFIG_S5P_DEV_CSIS0) += dev-csis0.o |
32 | obj-$(CONFIG_S5P_DEV_CSIS1) += dev-csis1.o | 32 | obj-$(CONFIG_S5P_DEV_CSIS1) += dev-csis1.o |
33 | obj-$(CONFIG_S5P_SYSMMU) += sysmmu.o | ||
diff --git a/arch/arm/plat-s5p/include/plat/sysmmu.h b/arch/arm/plat-s5p/include/plat/sysmmu.h new file mode 100644 index 000000000000..db298fc5438a --- /dev/null +++ b/arch/arm/plat-s5p/include/plat/sysmmu.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* linux/arch/arm/plat-s5p/include/plat/sysmmu.h | ||
2 | * | ||
3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com/ | ||
5 | * | ||
6 | * Samsung sysmmu driver | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #ifndef __ASM_PLAT_S5P_SYSMMU_H | ||
14 | #define __ASM_PLAT_S5P_SYSMMU_H __FILE__ | ||
15 | |||
16 | /* debug macro */ | ||
17 | #ifdef CONFIG_S5P_SYSMMU_DEBUG | ||
18 | #define sysmmu_debug(fmt, arg...) printk(KERN_INFO "[%s] " fmt, __func__, ## arg) | ||
19 | #else | ||
20 | #define sysmmu_debug(fmt, arg...) do { } while (0) | ||
21 | #endif | ||
22 | |||
23 | #endif /* __ASM_PLAT_S5P_SYSMMU_H */ | ||
diff --git a/arch/arm/plat-s5p/sysmmu.c b/arch/arm/plat-s5p/sysmmu.c new file mode 100644 index 000000000000..d804914dc2e2 --- /dev/null +++ b/arch/arm/plat-s5p/sysmmu.c | |||
@@ -0,0 +1,328 @@ | |||
1 | /* linux/arch/arm/plat-s5p/sysmmu.c | ||
2 | * | ||
3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/io.h> | ||
12 | #include <linux/interrupt.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | |||
15 | #include <mach/map.h> | ||
16 | #include <mach/regs-sysmmu.h> | ||
17 | #include <mach/sysmmu.h> | ||
18 | |||
19 | #include <plat/sysmmu.h> | ||
20 | |||
21 | struct sysmmu_controller s5p_sysmmu_cntlrs[S5P_SYSMMU_TOTAL_IPNUM]; | ||
22 | |||
23 | void s5p_sysmmu_register(struct sysmmu_controller *sysmmuconp) | ||
24 | { | ||
25 | unsigned int reg_mmu_ctrl; | ||
26 | unsigned int reg_mmu_status; | ||
27 | unsigned int reg_pt_base_addr; | ||
28 | unsigned int reg_int_status; | ||
29 | unsigned int reg_page_ft_addr; | ||
30 | |||
31 | reg_int_status = __raw_readl(sysmmuconp->regs + S5P_INT_STATUS); | ||
32 | reg_mmu_ctrl = __raw_readl(sysmmuconp->regs + S5P_MMU_CTRL); | ||
33 | reg_mmu_status = __raw_readl(sysmmuconp->regs + S5P_MMU_STATUS); | ||
34 | reg_pt_base_addr = __raw_readl(sysmmuconp->regs + S5P_PT_BASE_ADDR); | ||
35 | reg_page_ft_addr = __raw_readl(sysmmuconp->regs + S5P_PAGE_FAULT_ADDR); | ||
36 | |||
37 | printk(KERN_INFO "%s: ips:%s\n", __func__, sysmmuconp->name); | ||
38 | printk(KERN_INFO "%s: MMU_CTRL:0x%X, ", __func__, reg_mmu_ctrl); | ||
39 | printk(KERN_INFO "MMU_STATUS:0x%X, PT_BASE_ADDR:0x%X\n", reg_mmu_status, reg_pt_base_addr); | ||
40 | printk(KERN_INFO "%s: INT_STATUS:0x%X, PAGE_FAULT_ADDR:0x%X\n", __func__, reg_int_status, reg_page_ft_addr); | ||
41 | |||
42 | switch (reg_int_status & 0xFF) { | ||
43 | case 0x1: | ||
44 | printk(KERN_INFO "%s: Page fault\n", __func__); | ||
45 | printk(KERN_INFO "%s: Virtual address causing last page fault or bus error : 0x%x\n", __func__ , reg_page_ft_addr); | ||
46 | break; | ||
47 | case 0x2: | ||
48 | printk(KERN_INFO "%s: AR multi-hit fault\n", __func__); | ||
49 | break; | ||
50 | case 0x4: | ||
51 | printk(KERN_INFO "%s: AW multi-hit fault\n", __func__); | ||
52 | break; | ||
53 | case 0x8: | ||
54 | printk(KERN_INFO "%s: Bus error\n", __func__); | ||
55 | break; | ||
56 | case 0x10: | ||
57 | printk(KERN_INFO "%s: AR Security protection fault\n", __func__); | ||
58 | break; | ||
59 | case 0x20: | ||
60 | printk(KERN_INFO "%s: AR Access protection fault\n", __func__); | ||
61 | break; | ||
62 | case 0x40: | ||
63 | printk(KERN_INFO "%s: AW Security protection fault\n", __func__); | ||
64 | break; | ||
65 | case 0x80: | ||
66 | printk(KERN_INFO "%s: AW Access protection fault\n", __func__); | ||
67 | break; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | static irqreturn_t s5p_sysmmu_irq(int irq, void *dev_id) | ||
72 | { | ||
73 | unsigned int i; | ||
74 | unsigned int reg_int_status; | ||
75 | struct sysmmu_controller *sysmmuconp; | ||
76 | |||
77 | for (i = 0; i < S5P_SYSMMU_TOTAL_IPNUM; i++) { | ||
78 | sysmmuconp = &s5p_sysmmu_cntlrs[i]; | ||
79 | |||
80 | if (sysmmuconp->enable == true) { | ||
81 | reg_int_status = __raw_readl(sysmmuconp->regs + S5P_INT_STATUS); | ||
82 | |||
83 | if (reg_int_status & 0xFF) | ||
84 | s5p_sysmmu_register(sysmmuconp); | ||
85 | } | ||
86 | } | ||
87 | return IRQ_HANDLED; | ||
88 | } | ||
89 | |||
90 | int s5p_sysmmu_set_tablebase_pgd(sysmmu_ips ips, unsigned long pgd) | ||
91 | { | ||
92 | struct sysmmu_controller *sysmmuconp = NULL; | ||
93 | |||
94 | sysmmuconp = &s5p_sysmmu_cntlrs[ips]; | ||
95 | |||
96 | if (sysmmuconp == NULL) { | ||
97 | printk(KERN_ERR "failed to get ip's sysmmu info\n"); | ||
98 | return 1; | ||
99 | } | ||
100 | |||
101 | /* Set sysmmu page table base address */ | ||
102 | __raw_writel(pgd, sysmmuconp->regs + S5P_PT_BASE_ADDR); | ||
103 | |||
104 | if (s5p_sysmmu_tlb_invalidate(ips) != 0) | ||
105 | printk(KERN_ERR "failed s5p_sysmmu_tlb_invalidate\n"); | ||
106 | |||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | static int s5p_sysmmu_set_tablebase(sysmmu_ips ips) | ||
111 | { | ||
112 | unsigned int pg; | ||
113 | struct sysmmu_controller *sysmmuconp; | ||
114 | |||
115 | sysmmuconp = &s5p_sysmmu_cntlrs[ips]; | ||
116 | |||
117 | if (sysmmuconp == NULL) { | ||
118 | printk(KERN_ERR "failed to get ip's sysmmu info\n"); | ||
119 | return 1; | ||
120 | } | ||
121 | |||
122 | __asm__("mrc p15, 0, %0, c2, c0, 0" \ | ||
123 | : "=r" (pg) : : "cc"); \ | ||
124 | pg &= ~0x3fff; | ||
125 | |||
126 | sysmmu_debug("CP15 TTBR0 : 0x%x\n", pg); | ||
127 | |||
128 | /* Set sysmmu page table base address */ | ||
129 | __raw_writel(pg, sysmmuconp->regs + S5P_PT_BASE_ADDR); | ||
130 | |||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | int s5p_sysmmu_enable(sysmmu_ips ips) | ||
135 | { | ||
136 | unsigned int reg; | ||
137 | |||
138 | struct sysmmu_controller *sysmmuconp; | ||
139 | |||
140 | sysmmuconp = &s5p_sysmmu_cntlrs[ips]; | ||
141 | |||
142 | if (sysmmuconp == NULL) { | ||
143 | printk(KERN_ERR "failed to get ip's sysmmu info\n"); | ||
144 | return 1; | ||
145 | } | ||
146 | |||
147 | s5p_sysmmu_set_tablebase(ips); | ||
148 | |||
149 | /* replacement policy : LRU */ | ||
150 | reg = __raw_readl(sysmmuconp->regs + S5P_MMU_CFG); | ||
151 | reg |= 0x1; | ||
152 | __raw_writel(reg, sysmmuconp->regs + S5P_MMU_CFG); | ||
153 | |||
154 | /* Enable interrupt, Enable MMU */ | ||
155 | reg = __raw_readl(sysmmuconp->regs + S5P_MMU_CTRL); | ||
156 | reg |= (0x1 << 2) | (0x1 << 0); | ||
157 | |||
158 | __raw_writel(reg, sysmmuconp->regs + S5P_MMU_CTRL); | ||
159 | |||
160 | sysmmuconp->enable = true; | ||
161 | |||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | int s5p_sysmmu_disable(sysmmu_ips ips) | ||
166 | { | ||
167 | unsigned int reg; | ||
168 | |||
169 | struct sysmmu_controller *sysmmuconp = NULL; | ||
170 | |||
171 | if (ips > S5P_SYSMMU_TOTAL_IPNUM) | ||
172 | printk(KERN_ERR "failed to get ips parameter\n"); | ||
173 | |||
174 | sysmmuconp = &s5p_sysmmu_cntlrs[ips]; | ||
175 | |||
176 | if (sysmmuconp == NULL) { | ||
177 | printk(KERN_ERR "failed to get ip's sysmmu info\n"); | ||
178 | return 1; | ||
179 | } | ||
180 | |||
181 | reg = __raw_readl(sysmmuconp->regs + S5P_MMU_CFG); | ||
182 | |||
183 | /* replacement policy : LRU */ | ||
184 | reg |= 0x1; | ||
185 | __raw_writel(reg, sysmmuconp->regs + S5P_MMU_CFG); | ||
186 | |||
187 | reg = __raw_readl(sysmmuconp->regs + S5P_MMU_CTRL); | ||
188 | |||
189 | /* Disable MMU */ | ||
190 | reg &= ~0x1; | ||
191 | __raw_writel(reg, sysmmuconp->regs + S5P_MMU_CTRL); | ||
192 | |||
193 | sysmmuconp->enable = false; | ||
194 | |||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | int s5p_sysmmu_tlb_invalidate(sysmmu_ips ips) | ||
199 | { | ||
200 | unsigned int reg; | ||
201 | struct sysmmu_controller *sysmmuconp = NULL; | ||
202 | |||
203 | sysmmuconp = &s5p_sysmmu_cntlrs[ips]; | ||
204 | |||
205 | if (sysmmuconp == NULL) { | ||
206 | printk(KERN_ERR "failed to get ip's sysmmu info\n"); | ||
207 | return 1; | ||
208 | } | ||
209 | |||
210 | /* set Block MMU for flush TLB */ | ||
211 | reg = __raw_readl(sysmmuconp->regs + S5P_MMU_CTRL); | ||
212 | reg |= 0x1 << 1; | ||
213 | __raw_writel(reg, sysmmuconp->regs + S5P_MMU_CTRL); | ||
214 | |||
215 | /* flush all TLB entry */ | ||
216 | __raw_writel(0x1, sysmmuconp->regs + S5P_MMU_FLUSH); | ||
217 | |||
218 | /* set Un-block MMU after flush TLB */ | ||
219 | reg = __raw_readl(sysmmuconp->regs + S5P_MMU_CTRL); | ||
220 | reg &= ~(0x1 << 1); | ||
221 | __raw_writel(reg, sysmmuconp->regs + S5P_MMU_CTRL); | ||
222 | |||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | static int s5p_sysmmu_probe(struct platform_device *pdev) | ||
227 | { | ||
228 | int i; | ||
229 | int ret; | ||
230 | struct resource *res; | ||
231 | struct sysmmu_controller *sysmmuconp; | ||
232 | sysmmu_ips ips; | ||
233 | |||
234 | for (i = 0; i < S5P_SYSMMU_TOTAL_IPNUM; i++) { | ||
235 | sysmmuconp = &s5p_sysmmu_cntlrs[i]; | ||
236 | if (sysmmuconp == NULL) { | ||
237 | printk(KERN_ERR "failed to get ip's sysmmu info\n"); | ||
238 | ret = -ENOENT; | ||
239 | goto err_res; | ||
240 | } | ||
241 | |||
242 | sysmmuconp->name = sysmmu_ips_name[i]; | ||
243 | |||
244 | res = platform_get_resource(pdev, IORESOURCE_MEM, i); | ||
245 | if (!res) { | ||
246 | printk(KERN_ERR "failed to get sysmmu resource\n"); | ||
247 | ret = -ENODEV; | ||
248 | goto err_res; | ||
249 | } | ||
250 | |||
251 | sysmmuconp->mem = request_mem_region(res->start, | ||
252 | ((res->end) - (res->start)) + 1, pdev->name); | ||
253 | if (!sysmmuconp->mem) { | ||
254 | pr_err("failed to request sysmmu memory region\n"); | ||
255 | ret = -EBUSY; | ||
256 | goto err_res; | ||
257 | } | ||
258 | |||
259 | sysmmuconp->regs = ioremap(res->start, res->end - res->start + 1); | ||
260 | if (!sysmmuconp->regs) { | ||
261 | pr_err("failed to sysmmu ioremap\n"); | ||
262 | ret = -ENXIO; | ||
263 | goto err_reg; | ||
264 | } | ||
265 | |||
266 | sysmmuconp->irq = platform_get_irq(pdev, i); | ||
267 | if (sysmmuconp->irq <= 0) { | ||
268 | pr_err("failed to get sysmmu irq resource\n"); | ||
269 | ret = -ENOENT; | ||
270 | goto err_map; | ||
271 | } | ||
272 | |||
273 | ret = request_irq(sysmmuconp->irq, s5p_sysmmu_irq, IRQF_DISABLED, pdev->name, sysmmuconp); | ||
274 | if (ret) { | ||
275 | pr_err("failed to request irq\n"); | ||
276 | ret = -ENOENT; | ||
277 | goto err_map; | ||
278 | } | ||
279 | |||
280 | ips = (sysmmu_ips)i; | ||
281 | |||
282 | sysmmuconp->ips = ips; | ||
283 | } | ||
284 | |||
285 | return 0; | ||
286 | |||
287 | err_reg: | ||
288 | release_mem_region((resource_size_t)sysmmuconp->mem, (resource_size_t)((res->end) - (res->start) + 1)); | ||
289 | err_map: | ||
290 | iounmap(sysmmuconp->regs); | ||
291 | err_res: | ||
292 | return ret; | ||
293 | } | ||
294 | |||
295 | static int s5p_sysmmu_remove(struct platform_device *pdev) | ||
296 | { | ||
297 | return 0; | ||
298 | } | ||
299 | int s5p_sysmmu_runtime_suspend(struct device *dev) | ||
300 | { | ||
301 | return 0; | ||
302 | } | ||
303 | |||
304 | int s5p_sysmmu_runtime_resume(struct device *dev) | ||
305 | { | ||
306 | return 0; | ||
307 | } | ||
308 | |||
309 | const struct dev_pm_ops s5p_sysmmu_pm_ops = { | ||
310 | .runtime_suspend = s5p_sysmmu_runtime_suspend, | ||
311 | .runtime_resume = s5p_sysmmu_runtime_resume, | ||
312 | }; | ||
313 | |||
314 | static struct platform_driver s5p_sysmmu_driver = { | ||
315 | .probe = s5p_sysmmu_probe, | ||
316 | .remove = s5p_sysmmu_remove, | ||
317 | .driver = { | ||
318 | .owner = THIS_MODULE, | ||
319 | .name = "s5p-sysmmu", | ||
320 | .pm = &s5p_sysmmu_pm_ops, | ||
321 | } | ||
322 | }; | ||
323 | |||
324 | static int __init s5p_sysmmu_init(void) | ||
325 | { | ||
326 | return platform_driver_register(&s5p_sysmmu_driver); | ||
327 | } | ||
328 | arch_initcall(s5p_sysmmu_init); | ||