diff options
Diffstat (limited to 'arch/arm/plat-s5p')
-rw-r--r-- | arch/arm/plat-s5p/include/plat/s5p-iovmm.h | 46 | ||||
-rw-r--r-- | arch/arm/plat-s5p/include/plat/s5p-sysmmu.h | 31 | ||||
-rw-r--r-- | arch/arm/plat-s5p/include/plat/tvout.h | 16 | ||||
-rw-r--r-- | arch/arm/plat-s5p/reserve_mem.c | 4 | ||||
-rw-r--r-- | arch/arm/plat-s5p/s5p-sysmmu.c | 14 | ||||
-rw-r--r-- | arch/arm/plat-s5p/sysmmu.c | 312 |
6 files changed, 96 insertions, 327 deletions
diff --git a/arch/arm/plat-s5p/include/plat/s5p-iovmm.h b/arch/arm/plat-s5p/include/plat/s5p-iovmm.h index 2e31ce3..f22edc7 100644 --- a/arch/arm/plat-s5p/include/plat/s5p-iovmm.h +++ b/arch/arm/plat-s5p/include/plat/s5p-iovmm.h @@ -11,6 +11,50 @@ #ifndef __ASM_PLAT_IOVMM_H #define __ASM_PLAT_IOVMM_H +#ifdef CONFIG_DRM_EXYNOS_IOMMU +#ifdef CONFIG_IOVMM +void *iovmm_setup(unsigned long s_iova, unsigned long size); +void iovmm_cleanup(void *in_vmm); +int iovmm_activate(void *in_vmm, struct device *dev); +void iovmm_deactivate(void *in_vmm, struct device *dev); + +/* iovmm_map() - Maps a list of physical memory chunks + * @dev: the owner of the IO address space where the mapping is created + * @sg: list of physical memory chunks to map + * @offset: length in bytes where the mapping starts + * @size: how much memory to map in bytes. @offset + @size must not exceed + * total size of @sg + * + * This function returns mapped IO address in the address space of @dev. + * Returns 0 if mapping fails. + * + * The caller of this function must ensure that iovmm_cleanup() is not called + * while this function is called. + * + */ +dma_addr_t iovmm_map(void *in_vmm, struct scatterlist *sg, off_t offset, + size_t size); + +/* iovmm_map() - unmaps the given IO address + * @dev: the owner of the IO address space where @iova belongs + * @iova: IO address that needs to be unmapped and freed. + * + * The caller of this function must ensure that iovmm_cleanup() is not called + * while this function is called. + */ +void iovmm_unmap(void *in_vmm, dma_addr_t iova); + +#else +#define iovmm_setup(s_iova, size) (ERR_PTR(-ENOSYS)) +#define iovmm_cleanup(in_vmm) +#define iovmm_activate(in_vmm, dev) (-ENOSYS) +#define iovmm_deactivate(in_vmm, dev) +#define iovmm_map(in_vmm, sg, offset, size) (0) +#define iovmm_unmap(in_vmm, iova) +#endif /* CONFIG_IOVMM */ + +#else + #ifdef CONFIG_IOVMM int iovmm_setup(struct device *dev); void iovmm_cleanup(struct device *dev); @@ -52,4 +96,6 @@ void iovmm_unmap(struct device *dev, dma_addr_t iova); #define iovmm_unmap(dev, iova) #endif /* CONFIG_IOVMM */ +#endif /* CONFIG_DRM_EXYNOS_IOMMU */ + #endif /*__ASM_PLAT_IOVMM_H*/ diff --git a/arch/arm/plat-s5p/include/plat/s5p-sysmmu.h b/arch/arm/plat-s5p/include/plat/s5p-sysmmu.h index ad30a97..05aba31 100644 --- a/arch/arm/plat-s5p/include/plat/s5p-sysmmu.h +++ b/arch/arm/plat-s5p/include/plat/s5p-sysmmu.h @@ -40,7 +40,25 @@ enum S5P_SYSMMU_INTERRUPT_TYPE { typedef int (*s5p_sysmmu_fault_handler_t)(enum S5P_SYSMMU_INTERRUPT_TYPE itype, unsigned long pgtable_base, unsigned long fault_addr); +struct sysmmu_drvdata { + struct list_head node; + struct device *dev; + struct device *owner; + void __iomem *sfrbase; + struct clk *clk; + int activations; + rwlock_t lock; + s5p_sysmmu_fault_handler_t fault_handler; + unsigned long version; +}; + #ifdef CONFIG_S5P_SYSTEM_MMU + +struct sysmmu_drvdata *get_sysmmu_data(struct device *owner, + struct sysmmu_drvdata *start); + +struct list_head *get_sysmmu_list(void); + /** * s5p_sysmmu_enable() - enable system mmu * @owner: The device whose System MMU is about to be enabled. @@ -80,6 +98,19 @@ void s5p_sysmmu_set_tablebase_pgd(struct device *owner, unsigned long pgd); */ void s5p_sysmmu_tlb_invalidate(struct device *owner); +/** + * s5p_sysmmu_tlb_invalidate_entry() - flush a TLB entry in system mmu + * @owner: The device whose System MMU. + * @iova: device address to tlb entry to be invalidated. + * @count: entry count. + * + * This function flush all TLB entry in system mmu + */ +void s5p_sysmmu_tlb_invalidate_entry(struct device *owner, + unsigned long iova, + unsigned int count, + unsigned long page_size); + /** s5p_sysmmu_set_fault_handler() - Fault handler for System MMUs * Called when interrupt occurred by the System MMUs * The device drivers of peripheral devices that has a System MMU can implement diff --git a/arch/arm/plat-s5p/include/plat/tvout.h b/arch/arm/plat-s5p/include/plat/tvout.h index e649d69..d701269 100644 --- a/arch/arm/plat-s5p/include/plat/tvout.h +++ b/arch/arm/plat-s5p/include/plat/tvout.h @@ -15,6 +15,17 @@ struct platform_device; +#ifdef CONFIG_HDMI_TX_STRENGTH +struct s5p_tx_tuning { + u8 tx_ch; + u8 *tx_val; +}; + +struct s5p_platform_tvout { + struct s5p_tx_tuning *tx_tune; +}; +#endif + struct s5p_platform_hpd { void (*int_src_hdmi_hpd)(struct platform_device *pdev); void (*int_src_ext_hpd)(struct platform_device *pdev); @@ -41,6 +52,11 @@ struct s5p_platform_cec { extern void s5p_hdmi_cec_set_platdata(struct s5p_platform_cec *pd); + +#ifdef CONFIG_HDMI_TX_STRENGTH +extern void s5p_hdmi_tvout_set_platdata(struct s5p_platform_tvout *pd); +#endif + /* defined by architecture to configure gpio */ extern void s5p_cec_cfg_gpio(struct platform_device *pdev); diff --git a/arch/arm/plat-s5p/reserve_mem.c b/arch/arm/plat-s5p/reserve_mem.c index a103ec9..557938a 100644 --- a/arch/arm/plat-s5p/reserve_mem.c +++ b/arch/arm/plat-s5p/reserve_mem.c @@ -86,7 +86,7 @@ void __init s5p_cma_region_reserve(struct cma_region *regions_normal, reg->start = paddr; reg->reserved = 1; - pr_debug("S5P/CMA: Reserved 0x%08x/0x%08x for '%s'\n", + pr_info("S5P/CMA: Reserved 0x%08x/0x%08x for '%s'\n", reg->start, reg->size, reg->name); } else { pr_err("S5P/CMA: No free space in memory for '%s'\n", @@ -141,7 +141,7 @@ void __init s5p_cma_region_reserve(struct cma_region *regions_normal, } else size_secure = ALIGN(size_secure, align_secure); - pr_debug("S5P/CMA: " + pr_info("S5P/CMA: " "Reserving %#x for secure region aligned by %#x.\n", size_secure, align_secure); diff --git a/arch/arm/plat-s5p/s5p-sysmmu.c b/arch/arm/plat-s5p/s5p-sysmmu.c index 70edd49..71bca4f 100644 --- a/arch/arm/plat-s5p/s5p-sysmmu.c +++ b/arch/arm/plat-s5p/s5p-sysmmu.c @@ -55,21 +55,9 @@ static char *sysmmu_fault_name[SYSMMU_FAULTS_NUM] = { "UNKNOWN FAULT" }; -struct sysmmu_drvdata { - struct list_head node; - struct device *dev; - struct device *owner; - void __iomem *sfrbase; - struct clk *clk; - int activations; - rwlock_t lock; - s5p_sysmmu_fault_handler_t fault_handler; - unsigned long version; -}; - static LIST_HEAD(sysmmu_list); -static struct sysmmu_drvdata *get_sysmmu_data(struct device *owner, +struct sysmmu_drvdata *get_sysmmu_data(struct device *owner, struct sysmmu_drvdata *start) { if (start) { diff --git a/arch/arm/plat-s5p/sysmmu.c b/arch/arm/plat-s5p/sysmmu.c deleted file mode 100644 index 54f5edd..0000000 --- a/arch/arm/plat-s5p/sysmmu.c +++ /dev/null @@ -1,312 +0,0 @@ -/* linux/arch/arm/plat-s5p/sysmmu.c - * - * Copyright (c) 2010 Samsung Electronics Co., Ltd. - * http://www.samsung.com - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include <linux/io.h> -#include <linux/interrupt.h> -#include <linux/platform_device.h> - -#include <asm/pgtable.h> - -#include <mach/map.h> -#include <mach/regs-sysmmu.h> -#include <plat/sysmmu.h> - -#define CTRL_ENABLE 0x5 -#define CTRL_BLOCK 0x7 -#define CTRL_DISABLE 0x0 - -static struct device *dev; - -static unsigned short fault_reg_offset[SYSMMU_FAULTS_NUM] = { - S5P_PAGE_FAULT_ADDR, - S5P_AR_FAULT_ADDR, - S5P_AW_FAULT_ADDR, - S5P_DEFAULT_SLAVE_ADDR, - S5P_AR_FAULT_ADDR, - S5P_AR_FAULT_ADDR, - S5P_AW_FAULT_ADDR, - S5P_AW_FAULT_ADDR -}; - -static char *sysmmu_fault_name[SYSMMU_FAULTS_NUM] = { - "PAGE FAULT", - "AR MULTI-HIT FAULT", - "AW MULTI-HIT FAULT", - "BUS ERROR", - "AR SECURITY PROTECTION FAULT", - "AR ACCESS PROTECTION FAULT", - "AW SECURITY PROTECTION FAULT", - "AW ACCESS PROTECTION FAULT" -}; - -static int (*fault_handlers[S5P_SYSMMU_TOTAL_IPNUM])( - enum S5P_SYSMMU_INTERRUPT_TYPE itype, - unsigned long pgtable_base, - unsigned long fault_addr); - -/* - * If adjacent 2 bits are true, the system MMU is enabled. - * The system MMU is disabled, otherwise. - */ -static unsigned long sysmmu_states; - -static inline void set_sysmmu_active(sysmmu_ips ips) -{ - sysmmu_states |= 3 << (ips * 2); -} - -static inline void set_sysmmu_inactive(sysmmu_ips ips) -{ - sysmmu_states &= ~(3 << (ips * 2)); -} - -static inline int is_sysmmu_active(sysmmu_ips ips) -{ - return sysmmu_states & (3 << (ips * 2)); -} - -static void __iomem *sysmmusfrs[S5P_SYSMMU_TOTAL_IPNUM]; - -static inline void sysmmu_block(sysmmu_ips ips) -{ - __raw_writel(CTRL_BLOCK, sysmmusfrs[ips] + S5P_MMU_CTRL); - dev_dbg(dev, "%s is blocked.\n", sysmmu_ips_name[ips]); -} - -static inline void sysmmu_unblock(sysmmu_ips ips) -{ - __raw_writel(CTRL_ENABLE, sysmmusfrs[ips] + S5P_MMU_CTRL); - dev_dbg(dev, "%s is unblocked.\n", sysmmu_ips_name[ips]); -} - -static inline void __sysmmu_tlb_invalidate(sysmmu_ips ips) -{ - __raw_writel(0x1, sysmmusfrs[ips] + S5P_MMU_FLUSH); - dev_dbg(dev, "TLB of %s is invalidated.\n", sysmmu_ips_name[ips]); -} - -static inline void __sysmmu_set_ptbase(sysmmu_ips ips, unsigned long pgd) -{ - if (unlikely(pgd == 0)) { - pgd = (unsigned long)ZERO_PAGE(0); - __raw_writel(0x20, sysmmusfrs[ips] + S5P_MMU_CFG); /* 4KB LV1 */ - } else { - __raw_writel(0x0, sysmmusfrs[ips] + S5P_MMU_CFG); /* 16KB LV1 */ - } - - __raw_writel(pgd, sysmmusfrs[ips] + S5P_PT_BASE_ADDR); - - dev_dbg(dev, "Page table base of %s is initialized with 0x%08lX.\n", - sysmmu_ips_name[ips], pgd); - __sysmmu_tlb_invalidate(ips); -} - -void sysmmu_set_fault_handler(sysmmu_ips ips, - int (*handler)(enum S5P_SYSMMU_INTERRUPT_TYPE itype, - unsigned long pgtable_base, - unsigned long fault_addr)) -{ - BUG_ON(!((ips >= SYSMMU_MDMA) && (ips < S5P_SYSMMU_TOTAL_IPNUM))); - fault_handlers[ips] = handler; -} - -static irqreturn_t s5p_sysmmu_irq(int irq, void *dev_id) -{ - /* SYSMMU is in blocked when interrupt occurred. */ - unsigned long base = 0; - sysmmu_ips ips = (sysmmu_ips)dev_id; - enum S5P_SYSMMU_INTERRUPT_TYPE itype; - - itype = (enum S5P_SYSMMU_INTERRUPT_TYPE) - __ffs(__raw_readl(sysmmusfrs[ips] + S5P_INT_STATUS)); - - BUG_ON(!((itype >= 0) && (itype < 8))); - - dev_alert(dev, "%s occurred by %s.\n", sysmmu_fault_name[itype], - sysmmu_ips_name[ips]); - - if (fault_handlers[ips]) { - unsigned long addr; - - base = __raw_readl(sysmmusfrs[ips] + S5P_PT_BASE_ADDR); - addr = __raw_readl(sysmmusfrs[ips] + fault_reg_offset[itype]); - - if (fault_handlers[ips](itype, base, addr)) { - __raw_writel(1 << itype, - sysmmusfrs[ips] + S5P_INT_CLEAR); - dev_notice(dev, "%s from %s is resolved." - " Retrying translation.\n", - sysmmu_fault_name[itype], sysmmu_ips_name[ips]); - } else { - base = 0; - } - } - - sysmmu_unblock(ips); - - if (!base) - dev_notice(dev, "%s from %s is not handled.\n", - sysmmu_fault_name[itype], sysmmu_ips_name[ips]); - - return IRQ_HANDLED; -} - -void s5p_sysmmu_set_tablebase_pgd(sysmmu_ips ips, unsigned long pgd) -{ - if (is_sysmmu_active(ips)) { - sysmmu_block(ips); - __sysmmu_set_ptbase(ips, pgd); - sysmmu_unblock(ips); - } else { - dev_dbg(dev, "%s is disabled. " - "Skipping initializing page table base.\n", - sysmmu_ips_name[ips]); - } -} - -void s5p_sysmmu_enable(sysmmu_ips ips, unsigned long pgd) -{ - if (!is_sysmmu_active(ips)) { - sysmmu_clk_enable(ips); - - __sysmmu_set_ptbase(ips, pgd); - - __raw_writel(CTRL_ENABLE, sysmmusfrs[ips] + S5P_MMU_CTRL); - - set_sysmmu_active(ips); - dev_dbg(dev, "%s is enabled.\n", sysmmu_ips_name[ips]); - } else { - dev_dbg(dev, "%s is already enabled.\n", sysmmu_ips_name[ips]); - } -} - -void s5p_sysmmu_disable(sysmmu_ips ips) -{ - if (is_sysmmu_active(ips)) { - __raw_writel(CTRL_DISABLE, sysmmusfrs[ips] + S5P_MMU_CTRL); - set_sysmmu_inactive(ips); - sysmmu_clk_disable(ips); - dev_dbg(dev, "%s is disabled.\n", sysmmu_ips_name[ips]); - } else { - dev_dbg(dev, "%s is already disabled.\n", sysmmu_ips_name[ips]); - } -} - -void s5p_sysmmu_tlb_invalidate(sysmmu_ips ips) -{ - if (is_sysmmu_active(ips)) { - sysmmu_block(ips); - __sysmmu_tlb_invalidate(ips); - sysmmu_unblock(ips); - } else { - dev_dbg(dev, "%s is disabled. " - "Skipping invalidating TLB.\n", sysmmu_ips_name[ips]); - } -} - -static int s5p_sysmmu_probe(struct platform_device *pdev) -{ - int i, ret; - struct resource *res, *mem; - - dev = &pdev->dev; - - for (i = 0; i < S5P_SYSMMU_TOTAL_IPNUM; i++) { - int irq; - - sysmmu_clk_init(dev, i); - sysmmu_clk_disable(i); - - res = platform_get_resource(pdev, IORESOURCE_MEM, i); - if (!res) { - dev_err(dev, "Failed to get the resource of %s.\n", - sysmmu_ips_name[i]); - ret = -ENODEV; - goto err_res; - } - - mem = request_mem_region(res->start, - ((res->end) - (res->start)) + 1, pdev->name); - if (!mem) { - dev_err(dev, "Failed to request the memory region of %s.\n", - sysmmu_ips_name[i]); - ret = -EBUSY; - goto err_res; - } - - sysmmusfrs[i] = ioremap(res->start, res->end - res->start + 1); - if (!sysmmusfrs[i]) { - dev_err(dev, "Failed to ioremap() for %s.\n", - sysmmu_ips_name[i]); - ret = -ENXIO; - goto err_reg; - } - - irq = platform_get_irq(pdev, i); - if (irq <= 0) { - dev_err(dev, "Failed to get the IRQ resource of %s.\n", - sysmmu_ips_name[i]); - ret = -ENOENT; - goto err_map; - } - - if (request_irq(irq, s5p_sysmmu_irq, IRQF_DISABLED, - pdev->name, (void *)i)) { - dev_err(dev, "Failed to request IRQ for %s.\n", - sysmmu_ips_name[i]); - ret = -ENOENT; - goto err_map; - } - } - - return 0; - -err_map: - iounmap(sysmmusfrs[i]); -err_reg: - release_mem_region(mem->start, resource_size(mem)); -err_res: - return ret; -} - -static int s5p_sysmmu_remove(struct platform_device *pdev) -{ - return 0; -} -int s5p_sysmmu_runtime_suspend(struct device *dev) -{ - return 0; -} - -int s5p_sysmmu_runtime_resume(struct device *dev) -{ - return 0; -} - -const struct dev_pm_ops s5p_sysmmu_pm_ops = { - .runtime_suspend = s5p_sysmmu_runtime_suspend, - .runtime_resume = s5p_sysmmu_runtime_resume, -}; - -static struct platform_driver s5p_sysmmu_driver = { - .probe = s5p_sysmmu_probe, - .remove = s5p_sysmmu_remove, - .driver = { - .owner = THIS_MODULE, - .name = "s5p-sysmmu", - .pm = &s5p_sysmmu_pm_ops, - } -}; - -static int __init s5p_sysmmu_init(void) -{ - return platform_driver_register(&s5p_sysmmu_driver); -} -arch_initcall(s5p_sysmmu_init); |