diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-05 18:57:04 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-05 18:57:04 -0400 |
| commit | eb3d3ec567e868c8a3bfbfdfc9465ffd52983d11 (patch) | |
| tree | 75acf38b8d73cd281e5ce4dcc941faf48e244b98 /drivers/of | |
| parent | c3c55a07203947f72afa50a3218460b27307c47d (diff) | |
| parent | bd63ce27d9d62bc40a962b991cbbbe4f0dc913d2 (diff) | |
Merge branch 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm into next
Pull ARM updates from Russell King:
- Major clean-up of the L2 cache support code. The existing mess was
becoming rather unmaintainable through all the additions that others
have done over time. This turns it into a much nicer structure, and
implements a few performance improvements as well.
- Clean up some of the CP15 control register tweaks for alignment
support, moving some code and data into alignment.c
- DMA properties for ARM, from Santosh and reviewed by DT people. This
adds DT properties to specify bus translations we can't discover
automatically, and to indicate whether devices are coherent.
- Hibernation support for ARM
- Make ftrace work with read-only text in modules
- add suspend support for PJ4B CPUs
- rework interrupt masking for undefined instruction handling, which
allows us to enable interrupts earlier in the handling of these
exceptions.
- support for big endian page tables
- fix stacktrace support to exclude stacktrace functions from the
trace, and add save_stack_trace_regs() implementation so that kprobes
can record stack traces.
- Add support for the Cortex-A17 CPU.
- Remove last vestiges of ARM710 support.
- Removal of ARM "meminfo" structure, finally converting us solely to
memblock to handle the early memory initialisation.
* 'for-linus' of git://ftp.arm.linux.org.uk/~rmk/linux-arm: (142 commits)
ARM: ensure C page table setup code follows assembly code (part II)
ARM: ensure C page table setup code follows assembly code
ARM: consolidate last remaining open-coded alignment trap enable
ARM: remove global cr_no_alignment
ARM: remove CPU_CP15 conditional from alignment.c
ARM: remove unused adjust_cr() function
ARM: move "noalign" command line option to alignment.c
ARM: provide common method to clear bits in CPU control register
ARM: 8025/1: Get rid of meminfo
ARM: 8060/1: mm: allow sub-architectures to override PCI I/O memory type
ARM: 8066/1: correction for ARM patch 8031/2
ARM: 8049/1: ftrace/add save_stack_trace_regs() implementation
ARM: 8065/1: remove last use of CONFIG_CPU_ARM710
ARM: 8062/1: Modify ldrt fixup handler to re-execute the userspace instruction
ARM: 8047/1: rwsem: use asm-generic rwsem implementation
ARM: l2c: trial at enabling some Cortex-A9 optimisations
ARM: l2c: add warnings for stuff modifying aux_ctrl register values
ARM: l2c: print a warning with L2C-310 caches if the cache size is modified
ARM: l2c: remove old .set_debug method
ARM: l2c: kill L2X0_AUX_CTRL_MASK before anyone else makes use of this
...
Diffstat (limited to 'drivers/of')
| -rw-r--r-- | drivers/of/address.c | 110 | ||||
| -rw-r--r-- | drivers/of/platform.c | 65 |
2 files changed, 169 insertions, 6 deletions
diff --git a/drivers/of/address.c b/drivers/of/address.c index 95351b2a112c..5edfcb0da37d 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c | |||
| @@ -701,3 +701,113 @@ void __iomem *of_iomap(struct device_node *np, int index) | |||
| 701 | return ioremap(res.start, resource_size(&res)); | 701 | return ioremap(res.start, resource_size(&res)); |
| 702 | } | 702 | } |
| 703 | EXPORT_SYMBOL(of_iomap); | 703 | EXPORT_SYMBOL(of_iomap); |
| 704 | |||
| 705 | /** | ||
| 706 | * of_dma_get_range - Get DMA range info | ||
| 707 | * @np: device node to get DMA range info | ||
| 708 | * @dma_addr: pointer to store initial DMA address of DMA range | ||
| 709 | * @paddr: pointer to store initial CPU address of DMA range | ||
| 710 | * @size: pointer to store size of DMA range | ||
| 711 | * | ||
| 712 | * Look in bottom up direction for the first "dma-ranges" property | ||
| 713 | * and parse it. | ||
| 714 | * dma-ranges format: | ||
| 715 | * DMA addr (dma_addr) : naddr cells | ||
| 716 | * CPU addr (phys_addr_t) : pna cells | ||
| 717 | * size : nsize cells | ||
| 718 | * | ||
| 719 | * It returns -ENODEV if "dma-ranges" property was not found | ||
| 720 | * for this device in DT. | ||
| 721 | */ | ||
| 722 | int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *size) | ||
| 723 | { | ||
| 724 | struct device_node *node = of_node_get(np); | ||
| 725 | const __be32 *ranges = NULL; | ||
| 726 | int len, naddr, nsize, pna; | ||
| 727 | int ret = 0; | ||
| 728 | u64 dmaaddr; | ||
| 729 | |||
| 730 | if (!node) | ||
| 731 | return -EINVAL; | ||
| 732 | |||
| 733 | while (1) { | ||
| 734 | naddr = of_n_addr_cells(node); | ||
| 735 | nsize = of_n_size_cells(node); | ||
| 736 | node = of_get_next_parent(node); | ||
| 737 | if (!node) | ||
| 738 | break; | ||
| 739 | |||
| 740 | ranges = of_get_property(node, "dma-ranges", &len); | ||
| 741 | |||
| 742 | /* Ignore empty ranges, they imply no translation required */ | ||
| 743 | if (ranges && len > 0) | ||
| 744 | break; | ||
| 745 | |||
| 746 | /* | ||
| 747 | * At least empty ranges has to be defined for parent node if | ||
| 748 | * DMA is supported | ||
| 749 | */ | ||
| 750 | if (!ranges) | ||
| 751 | break; | ||
| 752 | } | ||
| 753 | |||
| 754 | if (!ranges) { | ||
| 755 | pr_debug("%s: no dma-ranges found for node(%s)\n", | ||
| 756 | __func__, np->full_name); | ||
| 757 | ret = -ENODEV; | ||
| 758 | goto out; | ||
| 759 | } | ||
| 760 | |||
| 761 | len /= sizeof(u32); | ||
| 762 | |||
| 763 | pna = of_n_addr_cells(node); | ||
| 764 | |||
| 765 | /* dma-ranges format: | ||
| 766 | * DMA addr : naddr cells | ||
| 767 | * CPU addr : pna cells | ||
| 768 | * size : nsize cells | ||
| 769 | */ | ||
| 770 | dmaaddr = of_read_number(ranges, naddr); | ||
| 771 | *paddr = of_translate_dma_address(np, ranges); | ||
| 772 | if (*paddr == OF_BAD_ADDR) { | ||
| 773 | pr_err("%s: translation of DMA address(%pad) to CPU address failed node(%s)\n", | ||
| 774 | __func__, dma_addr, np->full_name); | ||
| 775 | ret = -EINVAL; | ||
| 776 | goto out; | ||
| 777 | } | ||
| 778 | *dma_addr = dmaaddr; | ||
| 779 | |||
| 780 | *size = of_read_number(ranges + naddr + pna, nsize); | ||
| 781 | |||
| 782 | pr_debug("dma_addr(%llx) cpu_addr(%llx) size(%llx)\n", | ||
| 783 | *dma_addr, *paddr, *size); | ||
| 784 | |||
| 785 | out: | ||
| 786 | of_node_put(node); | ||
| 787 | |||
| 788 | return ret; | ||
| 789 | } | ||
| 790 | EXPORT_SYMBOL_GPL(of_dma_get_range); | ||
| 791 | |||
| 792 | /** | ||
| 793 | * of_dma_is_coherent - Check if device is coherent | ||
| 794 | * @np: device node | ||
| 795 | * | ||
| 796 | * It returns true if "dma-coherent" property was found | ||
| 797 | * for this device in DT. | ||
| 798 | */ | ||
| 799 | bool of_dma_is_coherent(struct device_node *np) | ||
| 800 | { | ||
| 801 | struct device_node *node = of_node_get(np); | ||
| 802 | |||
| 803 | while (node) { | ||
| 804 | if (of_property_read_bool(node, "dma-coherent")) { | ||
| 805 | of_node_put(node); | ||
| 806 | return true; | ||
| 807 | } | ||
| 808 | node = of_get_next_parent(node); | ||
| 809 | } | ||
| 810 | of_node_put(node); | ||
| 811 | return false; | ||
| 812 | } | ||
| 813 | EXPORT_SYMBOL_GPL(of_dma_is_coherent); | ||
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 92c060e58b02..d90a02d89f51 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
| @@ -153,6 +153,64 @@ struct platform_device *of_device_alloc(struct device_node *np, | |||
| 153 | EXPORT_SYMBOL(of_device_alloc); | 153 | EXPORT_SYMBOL(of_device_alloc); |
| 154 | 154 | ||
| 155 | /** | 155 | /** |
| 156 | * of_dma_configure - Setup DMA configuration | ||
| 157 | * @dev: Device to apply DMA configuration | ||
| 158 | * | ||
| 159 | * Try to get devices's DMA configuration from DT and update it | ||
| 160 | * accordingly. | ||
| 161 | * | ||
| 162 | * In case if platform code need to use own special DMA configuration,it | ||
| 163 | * can use Platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE event | ||
| 164 | * to fix up DMA configuration. | ||
| 165 | */ | ||
| 166 | static void of_dma_configure(struct platform_device *pdev) | ||
| 167 | { | ||
| 168 | u64 dma_addr, paddr, size; | ||
| 169 | int ret; | ||
| 170 | struct device *dev = &pdev->dev; | ||
| 171 | |||
| 172 | #if defined(CONFIG_MICROBLAZE) | ||
| 173 | pdev->archdata.dma_mask = 0xffffffffUL; | ||
| 174 | #endif | ||
| 175 | |||
| 176 | /* | ||
| 177 | * Set default dma-mask to 32 bit. Drivers are expected to setup | ||
| 178 | * the correct supported dma_mask. | ||
| 179 | */ | ||
| 180 | dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
| 181 | |||
| 182 | /* | ||
| 183 | * Set it to coherent_dma_mask by default if the architecture | ||
| 184 | * code has not set it. | ||
| 185 | */ | ||
| 186 | if (!dev->dma_mask) | ||
| 187 | dev->dma_mask = &dev->coherent_dma_mask; | ||
| 188 | |||
| 189 | /* | ||
| 190 | * if dma-coherent property exist, call arch hook to setup | ||
| 191 | * dma coherent operations. | ||
| 192 | */ | ||
| 193 | if (of_dma_is_coherent(dev->of_node)) { | ||
| 194 | set_arch_dma_coherent_ops(dev); | ||
| 195 | dev_dbg(dev, "device is dma coherent\n"); | ||
| 196 | } | ||
| 197 | |||
| 198 | /* | ||
| 199 | * if dma-ranges property doesn't exist - just return else | ||
| 200 | * setup the dma offset | ||
| 201 | */ | ||
| 202 | ret = of_dma_get_range(dev->of_node, &dma_addr, &paddr, &size); | ||
| 203 | if (ret < 0) { | ||
| 204 | dev_dbg(dev, "no dma range information to setup\n"); | ||
| 205 | return; | ||
| 206 | } | ||
| 207 | |||
| 208 | /* DMA ranges found. Calculate and set dma_pfn_offset */ | ||
| 209 | dev->dma_pfn_offset = PFN_DOWN(paddr - dma_addr); | ||
| 210 | dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", dev->dma_pfn_offset); | ||
| 211 | } | ||
| 212 | |||
| 213 | /** | ||
| 156 | * of_platform_device_create_pdata - Alloc, initialize and register an of_device | 214 | * of_platform_device_create_pdata - Alloc, initialize and register an of_device |
| 157 | * @np: pointer to node to create device for | 215 | * @np: pointer to node to create device for |
| 158 | * @bus_id: name to assign device | 216 | * @bus_id: name to assign device |
| @@ -178,12 +236,7 @@ static struct platform_device *of_platform_device_create_pdata( | |||
| 178 | if (!dev) | 236 | if (!dev) |
| 179 | goto err_clear_flag; | 237 | goto err_clear_flag; |
| 180 | 238 | ||
| 181 | #if defined(CONFIG_MICROBLAZE) | 239 | of_dma_configure(dev); |
| 182 | dev->archdata.dma_mask = 0xffffffffUL; | ||
| 183 | #endif | ||
| 184 | dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); | ||
| 185 | if (!dev->dev.dma_mask) | ||
| 186 | dev->dev.dma_mask = &dev->dev.coherent_dma_mask; | ||
| 187 | dev->dev.bus = &platform_bus_type; | 240 | dev->dev.bus = &platform_bus_type; |
| 188 | dev->dev.platform_data = platform_data; | 241 | dev->dev.platform_data = platform_data; |
| 189 | 242 | ||
