Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets

Switch the omap1510 platform ohci device to use dma_direct_set_offset
to set the DMA offset instead of using direct hooks into the DMA
mapping code and remove the now unused hooks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Acked-by: Tony Lindgren <tony@atomide.com>

+22 -49
-18
arch/arm/include/asm/dma-direct.h
··· 9 9 * functions used internally by the DMA-mapping API to provide DMA 10 10 * addresses. They must not be used by drivers. 11 11 */ 12 - #ifndef __arch_pfn_to_dma 13 12 static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) 14 13 { 15 14 if (dev && dev->dma_range_map) ··· 32 33 33 34 return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); 34 35 } 35 - 36 - #else 37 - static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) 38 - { 39 - return __arch_pfn_to_dma(dev, pfn); 40 - } 41 - 42 - static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) 43 - { 44 - return __arch_dma_to_pfn(dev, addr); 45 - } 46 - 47 - static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) 48 - { 49 - return __arch_virt_to_dma(dev, addr); 50 - } 51 - #endif 52 36 53 37 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) 54 38 {
-31
arch/arm/mach-omap1/include/mach/memory.h
··· 14 14 * OMAP-1510 bus address is translated into a Local Bus address if the 15 15 * OMAP bus type is lbus. We do the address translation based on the 16 16 * device overriding the defaults used in the dma-mapping API. 17 - * Note that the is_lbus_device() test is not very efficient on 1510 18 - * because of the strncmp(). 19 17 */ 20 - #if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__) 21 18 22 19 /* 23 20 * OMAP-1510 Local Bus address offset 24 21 */ 25 22 #define OMAP1510_LB_OFFSET UL(0x30000000) 26 - 27 - #define virt_to_lbus(x) ((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET) 28 - #define lbus_to_virt(x) ((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET) 29 - #define is_lbus_device(dev) (cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0)) 30 - 31 - #define __arch_pfn_to_dma(dev, pfn) \ 32 - ({ dma_addr_t __dma = __pfn_to_phys(pfn); \ 33 - if (is_lbus_device(dev)) \ 34 - __dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \ 35 - __dma; }) 36 - 37 - #define __arch_dma_to_pfn(dev, addr) \ 38 - ({ dma_addr_t __dma = addr; \ 39 - if (is_lbus_device(dev)) \ 40 - __dma += PHYS_OFFSET - OMAP1510_LB_OFFSET; \ 41 - __phys_to_pfn(__dma); \ 42 - }) 43 - 44 - #define __arch_dma_to_virt(dev, addr) ({ (void *) (is_lbus_device(dev) ? \ 45 - lbus_to_virt(addr) : \ 46 - __phys_to_virt(addr)); }) 47 - 48 - #define __arch_virt_to_dma(dev, addr) ({ unsigned long __addr = (unsigned long)(addr); \ 49 - (dma_addr_t) (is_lbus_device(dev) ? \ 50 - virt_to_lbus(__addr) : \ 51 - __virt_to_phys(__addr)); }) 52 - 53 - #endif /* CONFIG_ARCH_OMAP15XX */ 54 23 55 24 #endif
+22
arch/arm/mach-omap1/usb.c
··· 9 9 #include <linux/kernel.h> 10 10 #include <linux/init.h> 11 11 #include <linux/platform_device.h> 12 + #include <linux/dma-mapping.h> 12 13 #include <linux/io.h> 13 14 14 15 #include <asm/irq.h> ··· 543 542 /* ULPD_APLL_CTRL */ 544 543 #define APLL_NDPLL_SWITCH (1 << 0) 545 544 545 + static int omap_1510_usb_ohci_notifier(struct notifier_block *nb, 546 + unsigned long event, void *data) 547 + { 548 + struct device *dev = data; 549 + 550 + if (event != BUS_NOTIFY_ADD_DEVICE) 551 + return NOTIFY_DONE; 552 + 553 + if (strncmp(dev_name(dev), "ohci", 4) == 0 && 554 + dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET, 555 + (u64)-1)) 556 + WARN_ONCE(1, "failed to set DMA offset\n"); 557 + return NOTIFY_OK; 558 + } 559 + 560 + static struct notifier_block omap_1510_usb_ohci_nb = { 561 + .notifier_call = omap_1510_usb_ohci_notifier, 562 + }; 563 + 546 564 static void __init omap_1510_usb_init(struct omap_usb_config *config) 547 565 { 548 566 unsigned int val; ··· 620 600 if (config->register_host) { 621 601 int status; 622 602 603 + bus_register_notifier(&platform_bus_type, 604 + &omap_1510_usb_ohci_nb); 623 605 ohci_device.dev.platform_data = config; 624 606 status = platform_device_register(&ohci_device); 625 607 if (status)