470-MIPS-ath79-swizzle-pci-address-for-ar71xx.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. --- /dev/null
  2. +++ b/arch/mips/include/asm/mach-ath79/mangle-port.h
  3. @@ -0,0 +1,37 @@
  4. +/*
  5. + * Copyright (C) 2012 Gabor Juhos <[email protected]>
  6. + *
  7. + * This file was derived from: inlude/asm-mips/mach-generic/mangle-port.h
  8. + * Copyright (C) 2003, 2004 Ralf Baechle
  9. + *
  10. + * This program is free software; you can redistribute it and/or modify it
  11. + * under the terms of the GNU General Public License version 2 as published
  12. + * by the Free Software Foundation.
  13. + */
  14. +
  15. +#ifndef __ASM_MACH_ATH79_MANGLE_PORT_H
  16. +#define __ASM_MACH_ATH79_MANGLE_PORT_H
  17. +
  18. +#ifdef CONFIG_PCI_AR71XX
  19. +extern unsigned long (ath79_pci_swizzle_b)(unsigned long port);
  20. +extern unsigned long (ath79_pci_swizzle_w)(unsigned long port);
  21. +#else
  22. +#define ath79_pci_swizzle_b(port) (port)
  23. +#define ath79_pci_swizzle_w(port) (port)
  24. +#endif
  25. +
  26. +#define __swizzle_addr_b(port) ath79_pci_swizzle_b(port)
  27. +#define __swizzle_addr_w(port) ath79_pci_swizzle_w(port)
  28. +#define __swizzle_addr_l(port) (port)
  29. +#define __swizzle_addr_q(port) (port)
  30. +
  31. +# define ioswabb(a, x) (x)
  32. +# define __mem_ioswabb(a, x) (x)
  33. +# define ioswabw(a, x) (x)
  34. +# define __mem_ioswabw(a, x) cpu_to_le16(x)
  35. +# define ioswabl(a, x) (x)
  36. +# define __mem_ioswabl(a, x) cpu_to_le32(x)
  37. +# define ioswabq(a, x) (x)
  38. +# define __mem_ioswabq(a, x) cpu_to_le64(x)
  39. +
  40. +#endif /* __ASM_MACH_ATH79_MANGLE_PORT_H */
  41. --- a/arch/mips/pci/pci-ar71xx.c
  42. +++ b/arch/mips/pci/pci-ar71xx.c
  43. @@ -71,6 +71,45 @@ static const u32 ar71xx_pci_read_mask[8]
  44. 0, 0xff, 0xffff, 0, 0xffffffff, 0, 0, 0
  45. };
  46. +static unsigned long (*__ath79_pci_swizzle_b)(unsigned long port);
  47. +static unsigned long (*__ath79_pci_swizzle_w)(unsigned long port);
  48. +
  49. +static inline bool ar71xx_is_pci_addr(unsigned long port)
  50. +{
  51. + unsigned long phys = CPHYSADDR(port);
  52. +
  53. + return (phys >= AR71XX_PCI_MEM_BASE &&
  54. + phys < AR71XX_PCI_MEM_BASE + AR71XX_PCI_MEM_SIZE);
  55. +}
  56. +
  57. +static unsigned long ar71xx_pci_swizzle_b(unsigned long port)
  58. +{
  59. + return ar71xx_is_pci_addr(port) ? port ^ 3 : port;
  60. +}
  61. +
  62. +static unsigned long ar71xx_pci_swizzle_w(unsigned long port)
  63. +{
  64. + return ar71xx_is_pci_addr(port) ? port ^ 2 : port;
  65. +}
  66. +
  67. +unsigned long ath79_pci_swizzle_b(unsigned long port)
  68. +{
  69. + if (__ath79_pci_swizzle_b)
  70. + return __ath79_pci_swizzle_b(port);
  71. +
  72. + return port;
  73. +}
  74. +EXPORT_SYMBOL(ath79_pci_swizzle_b);
  75. +
  76. +unsigned long ath79_pci_swizzle_w(unsigned long port)
  77. +{
  78. + if (__ath79_pci_swizzle_w)
  79. + return __ath79_pci_swizzle_w(port);
  80. +
  81. + return port;
  82. +}
  83. +EXPORT_SYMBOL(ath79_pci_swizzle_w);
  84. +
  85. static inline u32 ar71xx_pci_get_ble(int where, int size, int local)
  86. {
  87. u32 t;
  88. @@ -279,6 +318,9 @@ static int ar71xx_pci_probe(struct platf
  89. register_pci_controller(&apc->pci_ctrl);
  90. + __ath79_pci_swizzle_b = ar71xx_pci_swizzle_b;
  91. + __ath79_pci_swizzle_w = ar71xx_pci_swizzle_w;
  92. +
  93. return 0;
  94. }