Advertisement
Guest User

mv643xx.patch

a guest
Apr 12th, 2012
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.73 KB | None | 0 0
  1. diff -Naur l4linux/arch/l4/kernel/arch-arm/mach_setup.c l4linux.new/arch/l4/kernel/arch-arm/mach_setup.c
  2. --- l4linux/arch/l4/kernel/arch-arm/mach_setup.c    2012-02-02 14:47:06.445920263 +0100
  3. +++ l4linux.new/arch/l4/kernel/arch-arm/mach_setup.c    2012-02-02 14:34:32.189950155 +0100
  4. @@ -5,6 +5,7 @@
  5.  #include <linux/platform_device.h>
  6.  #include <linux/ata_platform.h>
  7.  #include <linux/smsc911x.h>
  8. +#include <linux/mv643xx_eth.h>
  9.  #include <linux/slab.h>
  10.  #include <linux/list.h>
  11.  
  12. @@ -12,6 +13,25 @@
  13.  
  14.  #include <asm/l4x/dma.h>
  15.  
  16. +#define GE00_PHYS_BASE          0xf1070000
  17. +
  18. +#define CPU_CONFIG_ERROR_PROP   0x00000004
  19. +
  20. +#define CGC_GE0                 (1 << 0)
  21. +#define CGC_PEX0                (1 << 2)
  22. +#define CGC_DUNIT               (1 << 6)
  23. +#define CGC_RUNIT               (1 << 7)
  24. +#define CGC_RESERVED            (0x6 << 21)
  25. +
  26. +#define TARGET_DDR              0
  27. +
  28. +#define DDR_BASE_CS_OFF(n)      (0x0000 + ((n) << 3))
  29. +#define DDR_SIZE_CS_OFF(n)      (0x0004 + ((n) << 3))
  30. +
  31. +#define WIN_CTRL_OFF            0x0000
  32. +#define WIN_BASE_OFF            0x0004
  33. +#define WIN_REMAP_LO_OFF        0x0008
  34. +#define WIN_REMAP_HI_OFF        0x000c
  35.  
  36.  static int dev_init_done;
  37.  
  38. @@ -222,12 +242,191 @@
  39.         printk("Adding DMA memory to DMA allocator failed!\n");
  40.  }
  41.  
  42. +
  43. +struct mbus_dram_target_info kirkwood_mbus_dram_info;
  44. +
  45. +static __init void ge_complete(
  46. +   struct mv643xx_eth_shared_platform_data *orion_ge_shared_data,
  47. +   struct mbus_dram_target_info *mbus_dram_info, int tclk,
  48. +   struct resource *orion_ge_resource, unsigned long irq,
  49. +   struct platform_device *orion_ge_shared,
  50. +   struct mv643xx_eth_platform_data *eth_data,
  51. +   struct platform_device *orion_ge)
  52. +{
  53. +   orion_ge_shared_data->dram = mbus_dram_info;
  54. +   orion_ge_shared_data->t_clk = tclk;
  55. +   orion_ge_resource->start = irq;
  56. +   orion_ge_resource->end = irq;
  57. +   eth_data->shared = orion_ge_shared;
  58. +   orion_ge->dev.platform_data = eth_data;
  59. +
  60. +   platform_device_register(orion_ge_shared);
  61. +   platform_device_register(orion_ge);
  62. +  
  63. +   dmabounce_register_dev(&orion_ge->dev, 1024, 4096);
  64. +   dmabounce_register_dev(&orion_ge_shared->dev, 1024, 4096);
  65. +}
  66. +
  67. +struct mv643xx_eth_shared_platform_data orion_ge00_shared_data;
  68. +
  69. +static struct resource orion_ge00_shared_resources[] = {
  70. +   {
  71. +       .name   = "ge00 base",
  72. +   }, {
  73. +       .name   = "ge00 err irq",
  74. +   },
  75. +};
  76. +
  77. +static struct platform_device orion_ge00_shared = {
  78. +   .name       = MV643XX_ETH_SHARED_NAME,
  79. +   .id     = 0,
  80. +   .dev        = {
  81. +       .platform_data  = &orion_ge00_shared_data,
  82. +   },
  83. +};
  84. +
  85. +static struct resource orion_ge00_resources[] = {
  86. +   {
  87. +       .name   = "ge00 irq",
  88. +       .flags  = IORESOURCE_IRQ,
  89. +   },
  90. +};
  91. +
  92. +static struct platform_device orion_ge00 = {
  93. +   .name       = MV643XX_ETH_NAME,
  94. +   .id     = 0,
  95. +   .num_resources  = 1,
  96. +   .resource   = orion_ge00_resources,
  97. +   .dev        = {
  98. +       .coherent_dma_mask  = DMA_BIT_MASK(32),
  99. +   },
  100. +};
  101. +
  102. +static struct mv643xx_eth_platform_data sheevaplug_ge00_data = {
  103. +    .phy_addr  = MV643XX_ETH_PHY_ADDR(0),
  104. +};
  105. +
  106. +static void fill_resources(struct platform_device *device,
  107. +              struct resource *resources,
  108. +              resource_size_t mapbase,
  109. +              resource_size_t size,
  110. +              unsigned int irq)
  111. +{
  112. +   device->resource = resources;
  113. +   device->num_resources = 1;
  114. +   resources[0].flags = IORESOURCE_MEM;
  115. +   resources[0].start = mapbase;
  116. +   resources[0].end = mapbase + size;
  117. +
  118. +   if (irq != NO_IRQ) {
  119. +       device->num_resources++;
  120. +       resources[1].flags = IORESOURCE_IRQ;
  121. +       resources[1].start = irq;
  122. +       resources[1].end = irq;
  123. +   }
  124. +}
  125. +
  126. +void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  127. +{
  128. +   fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
  129. +              GE00_PHYS_BASE + 0x2000, SZ_16K - 1, 46);
  130. +   ge_complete(&orion_ge00_shared_data, &kirkwood_mbus_dram_info, 200000000,
  131. +           orion_ge00_resources, 11, &orion_ge00_shared,
  132. +           eth_data, &orion_ge00);
  133. +}
  134. +
  135. +void __iomem *bridge_base = 0;
  136. +void __iomem *BRIDGE_PHYS_BASE(void)
  137. +{
  138. +   if(bridge_base == 0)
  139. +       return ioremap(0xf1020000, 0xffff);
  140. +   return bridge_base;
  141. +}
  142. +
  143. +static int __init kirkwood_clock_gate(void)
  144. +{ 
  145. +   void __iomem *clk_gating_ctrl = BRIDGE_PHYS_BASE() + 0x11c;
  146. +   unsigned int kirkwood_clk_ctrl = CGC_DUNIT | CGC_RESERVED | CGC_GE0 | CGC_RUNIT;
  147. +
  148. +   /* Enable PCIe before activating the clk for ethernet */
  149. +   u32 curr = readl(clk_gating_ctrl);
  150. +   if (!(curr & CGC_PEX0))
  151. +       writel(curr | CGC_PEX0, clk_gating_ctrl);
  152. +
  153. +   writel(kirkwood_clk_ctrl, clk_gating_ctrl);
  154. +
  155. +   return 0;
  156. +}
  157. +
  158. +void __iomem* WIN_OFF(int n)
  159. +{
  160. +   return (BRIDGE_PHYS_BASE() + 0x0000 + ((n) << 4));
  161. +}
  162. +
  163. +static int __init cpu_win_can_remap(int win)
  164. +{
  165. +   if (win < 4)
  166. +       return 1;
  167. +   return 0;
  168. +}
  169. +
  170. +void __init kirkwood_setup_cpu_mbus(void)
  171. +{     
  172. +   void __iomem *addr;
  173. +   int i;
  174. +   int cs;
  175. +
  176. +   for (i = 0; i < 8; i++) {
  177. +       addr = (void __iomem *)WIN_OFF(i);
  178. +
  179. +       writel(0, addr + WIN_BASE_OFF);
  180. +       writel(0, addr + WIN_CTRL_OFF);
  181. +       if (cpu_win_can_remap(i)) {
  182. +           writel(0, addr + WIN_REMAP_LO_OFF);
  183. +           writel(0, addr + WIN_REMAP_HI_OFF);
  184. +       }
  185. +   }
  186. +
  187. +   kirkwood_mbus_dram_info.mbus_dram_target_id = TARGET_DDR;
  188. +
  189. +   addr = (ioremap(0xf1000000, 0xffff) + 0x1500);
  190. +
  191. +   for (i = 0, cs = 0; i < 4; i++) {
  192. +       u32 base = readl(addr + DDR_BASE_CS_OFF(i));
  193. +       u32 size = readl(addr + DDR_SIZE_CS_OFF(i));
  194. +
  195. +       if (size & 1) {
  196. +           struct mbus_dram_window *w;
  197. +
  198. +           w = &kirkwood_mbus_dram_info.cs[cs++];
  199. +           w->cs_index = i;
  200. +           w->mbus_attr = 0xf & ~(1 << i);
  201. +           w->base = base & 0xffff0000;
  202. +           w->size = (size | 0x0000ffff) + 1;
  203. +       }
  204. +   }
  205. +   kirkwood_mbus_dram_info.num_cs = cs;
  206. +}
  207. +
  208. +static L4X_DEVICE_CB(kirkwood_device_cb_mv643xx)
  209. +{
  210. +   void __iomem *CPU_CONFIG = (BRIDGE_PHYS_BASE() + 0x0100);
  211. +  
  212. +   writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
  213. +  
  214. +   kirkwood_setup_cpu_mbus();
  215. +   kirkwood_ge00_init(&sheevaplug_ge00_data);
  216. +
  217. +   kirkwood_clock_gate();
  218. +}
  219. +
  220.  static void register_platform_callbacks(void)
  221.  {
  222.     l4x_register_platform_device_callback("compactflash", realview_device_cb_pata);
  223.     l4x_register_platform_device_callback("smsc911x",     realview_device_cb_smsc);
  224.     l4x_register_platform_device_callback("aaci",         aaci_cb);
  225.     l4x_register_platform_device_callback("dmamem",       dmamem_cb);
  226. +   l4x_register_platform_device_callback("mv643xx",      kirkwood_device_cb_mv643xx);
  227.  }
  228.  
  229.  static void
  230. diff -Naur l4linux/drivers/net/Kconfig l4linux.new/drivers/net/Kconfig
  231. --- l4linux/drivers/net/Kconfig 2012-02-02 15:02:13.605884312 +0100
  232. +++ l4linux.new/drivers/net/Kconfig 2012-02-02 14:35:30.309947852 +0100
  233. @@ -2455,7 +2455,7 @@
  234.  
  235.  config MV643XX_ETH
  236.     tristate "Marvell Discovery (643XX) and Orion ethernet support"
  237. -   depends on (MV64X60 || PPC32 || PLAT_ORION) && INET
  238. +   depends on (MV64X60 || PPC32 || PLAT_ORION || L4) && INET
  239.     select INET_LRO
  240.     select PHYLIB
  241.     help
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement