Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * arch/arm/plat-orion/common.c
0003  *
0004  * Marvell Orion SoC common setup code used by multiple mach-/common.c
0005  *
0006  * This file is licensed under the terms of the GNU General Public
0007  * License version 2.  This program is licensed "as is" without any
0008  * warranty of any kind, whether express or implied.
0009  */
0010 
0011 #include <linux/kernel.h>
0012 #include <linux/init.h>
0013 #include <linux/platform_device.h>
0014 #include <linux/dma-mapping.h>
0015 #include <linux/serial_8250.h>
0016 #include <linux/ata_platform.h>
0017 #include <linux/clk.h>
0018 #include <linux/clkdev.h>
0019 #include <linux/mv643xx_eth.h>
0020 #include <linux/mv643xx_i2c.h>
0021 #include <linux/platform_data/dsa.h>
0022 #include <linux/platform_data/dma-mv_xor.h>
0023 #include <linux/platform_data/usb-ehci-orion.h>
0024 #include <plat/common.h>
0025 #include <linux/phy.h>
0026 
0027 /* Create a clkdev entry for a given device/clk */
0028 void __init orion_clkdev_add(const char *con_id, const char *dev_id,
0029                  struct clk *clk)
0030 {
0031     clkdev_create(clk, con_id, "%s", dev_id);
0032 }
0033 
0034 /* Create clkdev entries for all orion platforms except kirkwood.
0035    Kirkwood has gated clocks for some of its peripherals, so creates
0036    its own clkdev entries. For all the other orion devices, create
0037    clkdev entries to the tclk. */
0038 void __init orion_clkdev_init(struct clk *tclk)
0039 {
0040     orion_clkdev_add(NULL, "orion_spi.0", tclk);
0041     orion_clkdev_add(NULL, "orion_spi.1", tclk);
0042     orion_clkdev_add(NULL, MV643XX_ETH_NAME ".0", tclk);
0043     orion_clkdev_add(NULL, MV643XX_ETH_NAME ".1", tclk);
0044     orion_clkdev_add(NULL, MV643XX_ETH_NAME ".2", tclk);
0045     orion_clkdev_add(NULL, MV643XX_ETH_NAME ".3", tclk);
0046     orion_clkdev_add(NULL, "orion_wdt", tclk);
0047     orion_clkdev_add(NULL, MV64XXX_I2C_CTLR_NAME ".0", tclk);
0048 }
0049 
0050 /* Fill in the resources structure and link it into the platform
0051    device structure. There is always a memory region, and nearly
0052    always an interrupt.*/
0053 static void fill_resources(struct platform_device *device,
0054                struct resource *resources,
0055                resource_size_t mapbase,
0056                resource_size_t size)
0057 {
0058     device->resource = resources;
0059     device->num_resources = 1;
0060     resources[0].flags = IORESOURCE_MEM;
0061     resources[0].start = mapbase;
0062     resources[0].end = mapbase + size;
0063 }
0064 
0065 static void fill_resources_irq(struct platform_device *device,
0066                    struct resource *resources,
0067                    resource_size_t mapbase,
0068                    resource_size_t size,
0069                    unsigned int irq)
0070 {
0071     fill_resources(device, resources, mapbase, size);
0072 
0073     device->num_resources++;
0074     resources[1].flags = IORESOURCE_IRQ;
0075     resources[1].start = irq;
0076     resources[1].end = irq;
0077 }
0078 
0079 /*****************************************************************************
0080  * UART
0081  ****************************************************************************/
0082 static unsigned long __init uart_get_clk_rate(struct clk *clk)
0083 {
0084     clk_prepare_enable(clk);
0085     return clk_get_rate(clk);
0086 }
0087 
0088 static void __init uart_complete(
0089     struct platform_device *orion_uart,
0090     struct plat_serial8250_port *data,
0091     struct resource *resources,
0092     void __iomem *membase,
0093     resource_size_t mapbase,
0094     unsigned int irq,
0095     struct clk *clk)
0096 {
0097     data->mapbase = mapbase;
0098     data->membase = membase;
0099     data->irq = irq;
0100     data->uartclk = uart_get_clk_rate(clk);
0101     orion_uart->dev.platform_data = data;
0102 
0103     fill_resources_irq(orion_uart, resources, mapbase, 0xff, irq);
0104     platform_device_register(orion_uart);
0105 }
0106 
0107 /*****************************************************************************
0108  * UART0
0109  ****************************************************************************/
0110 static struct plat_serial8250_port orion_uart0_data[] = {
0111     {
0112         .flags      = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
0113         .iotype     = UPIO_MEM,
0114         .regshift   = 2,
0115     }, {
0116     },
0117 };
0118 
0119 static struct resource orion_uart0_resources[2];
0120 
0121 static struct platform_device orion_uart0 = {
0122     .name           = "serial8250",
0123     .id         = PLAT8250_DEV_PLATFORM,
0124 };
0125 
0126 void __init orion_uart0_init(void __iomem *membase,
0127                  resource_size_t mapbase,
0128                  unsigned int irq,
0129                  struct clk *clk)
0130 {
0131     uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources,
0132               membase, mapbase, irq, clk);
0133 }
0134 
0135 /*****************************************************************************
0136  * UART1
0137  ****************************************************************************/
0138 static struct plat_serial8250_port orion_uart1_data[] = {
0139     {
0140         .flags      = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
0141         .iotype     = UPIO_MEM,
0142         .regshift   = 2,
0143     }, {
0144     },
0145 };
0146 
0147 static struct resource orion_uart1_resources[2];
0148 
0149 static struct platform_device orion_uart1 = {
0150     .name           = "serial8250",
0151     .id         = PLAT8250_DEV_PLATFORM1,
0152 };
0153 
0154 void __init orion_uart1_init(void __iomem *membase,
0155                  resource_size_t mapbase,
0156                  unsigned int irq,
0157                  struct clk *clk)
0158 {
0159     uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources,
0160               membase, mapbase, irq, clk);
0161 }
0162 
0163 /*****************************************************************************
0164  * UART2
0165  ****************************************************************************/
0166 static struct plat_serial8250_port orion_uart2_data[] = {
0167     {
0168         .flags      = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
0169         .iotype     = UPIO_MEM,
0170         .regshift   = 2,
0171     }, {
0172     },
0173 };
0174 
0175 static struct resource orion_uart2_resources[2];
0176 
0177 static struct platform_device orion_uart2 = {
0178     .name           = "serial8250",
0179     .id         = PLAT8250_DEV_PLATFORM2,
0180 };
0181 
0182 void __init orion_uart2_init(void __iomem *membase,
0183                  resource_size_t mapbase,
0184                  unsigned int irq,
0185                  struct clk *clk)
0186 {
0187     uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources,
0188               membase, mapbase, irq, clk);
0189 }
0190 
0191 /*****************************************************************************
0192  * UART3
0193  ****************************************************************************/
0194 static struct plat_serial8250_port orion_uart3_data[] = {
0195     {
0196         .flags      = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
0197         .iotype     = UPIO_MEM,
0198         .regshift   = 2,
0199     }, {
0200     },
0201 };
0202 
0203 static struct resource orion_uart3_resources[2];
0204 
0205 static struct platform_device orion_uart3 = {
0206     .name           = "serial8250",
0207     .id         = 3,
0208 };
0209 
0210 void __init orion_uart3_init(void __iomem *membase,
0211                  resource_size_t mapbase,
0212                  unsigned int irq,
0213                  struct clk *clk)
0214 {
0215     uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources,
0216               membase, mapbase, irq, clk);
0217 }
0218 
0219 /*****************************************************************************
0220  * SoC RTC
0221  ****************************************************************************/
0222 static struct resource orion_rtc_resource[2];
0223 
0224 void __init orion_rtc_init(unsigned long mapbase,
0225                unsigned long irq)
0226 {
0227     orion_rtc_resource[0].start = mapbase;
0228     orion_rtc_resource[0].end = mapbase + SZ_32 - 1;
0229     orion_rtc_resource[0].flags = IORESOURCE_MEM;
0230     orion_rtc_resource[1].start = irq;
0231     orion_rtc_resource[1].end = irq;
0232     orion_rtc_resource[1].flags = IORESOURCE_IRQ;
0233 
0234     platform_device_register_simple("rtc-mv", -1, orion_rtc_resource, 2);
0235 }
0236 
0237 /*****************************************************************************
0238  * GE
0239  ****************************************************************************/
0240 static __init void ge_complete(
0241     struct mv643xx_eth_shared_platform_data *orion_ge_shared_data,
0242     struct resource *orion_ge_resource, unsigned long irq,
0243     struct platform_device *orion_ge_shared,
0244     struct platform_device *orion_ge_mvmdio,
0245     struct mv643xx_eth_platform_data *eth_data,
0246     struct platform_device *orion_ge)
0247 {
0248     orion_ge_resource->start = irq;
0249     orion_ge_resource->end = irq;
0250     eth_data->shared = orion_ge_shared;
0251     orion_ge->dev.platform_data = eth_data;
0252 
0253     platform_device_register(orion_ge_shared);
0254     if (orion_ge_mvmdio)
0255         platform_device_register(orion_ge_mvmdio);
0256     platform_device_register(orion_ge);
0257 }
0258 
0259 /*****************************************************************************
0260  * GE00
0261  ****************************************************************************/
0262 static struct mv643xx_eth_shared_platform_data orion_ge00_shared_data;
0263 
0264 static struct resource orion_ge00_shared_resources[] = {
0265     {
0266         .name   = "ge00 base",
0267     },
0268 };
0269 
0270 static struct platform_device orion_ge00_shared = {
0271     .name       = MV643XX_ETH_SHARED_NAME,
0272     .id     = 0,
0273     .dev        = {
0274         .platform_data  = &orion_ge00_shared_data,
0275     },
0276 };
0277 
0278 static struct resource orion_ge_mvmdio_resources[] = {
0279     {
0280         .name   = "ge00 mvmdio base",
0281     }, {
0282         .name   = "ge00 mvmdio err irq",
0283     },
0284 };
0285 
0286 static struct platform_device orion_ge_mvmdio = {
0287     .name       = "orion-mdio",
0288     .id     = -1,
0289 };
0290 
0291 static struct resource orion_ge00_resources[] = {
0292     {
0293         .name   = "ge00 irq",
0294         .flags  = IORESOURCE_IRQ,
0295     },
0296 };
0297 
0298 static struct platform_device orion_ge00 = {
0299     .name       = MV643XX_ETH_NAME,
0300     .id     = 0,
0301     .num_resources  = 1,
0302     .resource   = orion_ge00_resources,
0303     .dev        = {
0304         .coherent_dma_mask  = DMA_BIT_MASK(32),
0305     },
0306 };
0307 
0308 void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
0309                 unsigned long mapbase,
0310                 unsigned long irq,
0311                 unsigned long irq_err,
0312                 unsigned int tx_csum_limit)
0313 {
0314     fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
0315                mapbase + 0x2000, SZ_16K - 1);
0316     fill_resources_irq(&orion_ge_mvmdio, orion_ge_mvmdio_resources,
0317             mapbase + 0x2004, 0x84 - 1, irq_err);
0318     orion_ge00_shared_data.tx_csum_limit = tx_csum_limit;
0319     ge_complete(&orion_ge00_shared_data,
0320             orion_ge00_resources, irq, &orion_ge00_shared,
0321             &orion_ge_mvmdio,
0322             eth_data, &orion_ge00);
0323 }
0324 
0325 /*****************************************************************************
0326  * GE01
0327  ****************************************************************************/
0328 static struct mv643xx_eth_shared_platform_data orion_ge01_shared_data;
0329 
0330 static struct resource orion_ge01_shared_resources[] = {
0331     {
0332         .name   = "ge01 base",
0333     }
0334 };
0335 
0336 static struct platform_device orion_ge01_shared = {
0337     .name       = MV643XX_ETH_SHARED_NAME,
0338     .id     = 1,
0339     .dev        = {
0340         .platform_data  = &orion_ge01_shared_data,
0341     },
0342 };
0343 
0344 static struct resource orion_ge01_resources[] = {
0345     {
0346         .name   = "ge01 irq",
0347         .flags  = IORESOURCE_IRQ,
0348     },
0349 };
0350 
0351 static struct platform_device orion_ge01 = {
0352     .name       = MV643XX_ETH_NAME,
0353     .id     = 1,
0354     .num_resources  = 1,
0355     .resource   = orion_ge01_resources,
0356     .dev        = {
0357         .coherent_dma_mask  = DMA_BIT_MASK(32),
0358     },
0359 };
0360 
0361 void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
0362                 unsigned long mapbase,
0363                 unsigned long irq,
0364                 unsigned int tx_csum_limit)
0365 {
0366     fill_resources(&orion_ge01_shared, orion_ge01_shared_resources,
0367                mapbase + 0x2000, SZ_16K - 1);
0368     orion_ge01_shared_data.tx_csum_limit = tx_csum_limit;
0369     ge_complete(&orion_ge01_shared_data,
0370             orion_ge01_resources, irq, &orion_ge01_shared,
0371             NULL,
0372             eth_data, &orion_ge01);
0373 }
0374 
0375 /*****************************************************************************
0376  * GE10
0377  ****************************************************************************/
0378 static struct mv643xx_eth_shared_platform_data orion_ge10_shared_data;
0379 
0380 static struct resource orion_ge10_shared_resources[] = {
0381     {
0382         .name   = "ge10 base",
0383     }
0384 };
0385 
0386 static struct platform_device orion_ge10_shared = {
0387     .name       = MV643XX_ETH_SHARED_NAME,
0388     .id     = 2,
0389     .dev        = {
0390         .platform_data  = &orion_ge10_shared_data,
0391     },
0392 };
0393 
0394 static struct resource orion_ge10_resources[] = {
0395     {
0396         .name   = "ge10 irq",
0397         .flags  = IORESOURCE_IRQ,
0398     },
0399 };
0400 
0401 static struct platform_device orion_ge10 = {
0402     .name       = MV643XX_ETH_NAME,
0403     .id     = 2,
0404     .num_resources  = 1,
0405     .resource   = orion_ge10_resources,
0406     .dev        = {
0407         .coherent_dma_mask  = DMA_BIT_MASK(32),
0408     },
0409 };
0410 
0411 void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
0412                 unsigned long mapbase,
0413                 unsigned long irq)
0414 {
0415     fill_resources(&orion_ge10_shared, orion_ge10_shared_resources,
0416                mapbase + 0x2000, SZ_16K - 1);
0417     ge_complete(&orion_ge10_shared_data,
0418             orion_ge10_resources, irq, &orion_ge10_shared,
0419             NULL,
0420             eth_data, &orion_ge10);
0421 }
0422 
0423 /*****************************************************************************
0424  * GE11
0425  ****************************************************************************/
0426 static struct mv643xx_eth_shared_platform_data orion_ge11_shared_data;
0427 
0428 static struct resource orion_ge11_shared_resources[] = {
0429     {
0430         .name   = "ge11 base",
0431     },
0432 };
0433 
0434 static struct platform_device orion_ge11_shared = {
0435     .name       = MV643XX_ETH_SHARED_NAME,
0436     .id     = 3,
0437     .dev        = {
0438         .platform_data  = &orion_ge11_shared_data,
0439     },
0440 };
0441 
0442 static struct resource orion_ge11_resources[] = {
0443     {
0444         .name   = "ge11 irq",
0445         .flags  = IORESOURCE_IRQ,
0446     },
0447 };
0448 
0449 static struct platform_device orion_ge11 = {
0450     .name       = MV643XX_ETH_NAME,
0451     .id     = 3,
0452     .num_resources  = 1,
0453     .resource   = orion_ge11_resources,
0454     .dev        = {
0455         .coherent_dma_mask  = DMA_BIT_MASK(32),
0456     },
0457 };
0458 
0459 void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
0460                 unsigned long mapbase,
0461                 unsigned long irq)
0462 {
0463     fill_resources(&orion_ge11_shared, orion_ge11_shared_resources,
0464                mapbase + 0x2000, SZ_16K - 1);
0465     ge_complete(&orion_ge11_shared_data,
0466             orion_ge11_resources, irq, &orion_ge11_shared,
0467             NULL,
0468             eth_data, &orion_ge11);
0469 }
0470 
0471 #ifdef CONFIG_ARCH_ORION5X
0472 /*****************************************************************************
0473  * Ethernet switch
0474  ****************************************************************************/
0475 static __initdata struct mdio_board_info orion_ge00_switch_board_info = {
0476     .bus_id   = "orion-mii",
0477     .modalias = "mv88e6085",
0478 };
0479 
0480 void __init orion_ge00_switch_init(struct dsa_chip_data *d)
0481 {
0482     unsigned int i;
0483 
0484     if (!IS_BUILTIN(CONFIG_PHYLIB))
0485         return;
0486 
0487     for (i = 0; i < ARRAY_SIZE(d->port_names); i++) {
0488         if (!strcmp(d->port_names[i], "cpu")) {
0489             d->netdev[i] = &orion_ge00.dev;
0490             break;
0491         }
0492     }
0493 
0494     orion_ge00_switch_board_info.mdio_addr = d->sw_addr;
0495     orion_ge00_switch_board_info.platform_data = d;
0496 
0497     mdiobus_register_board_info(&orion_ge00_switch_board_info, 1);
0498 }
0499 #endif
0500 
0501 /*****************************************************************************
0502  * I2C
0503  ****************************************************************************/
0504 static struct mv64xxx_i2c_pdata orion_i2c_pdata = {
0505     .freq_n     = 3,
0506     .timeout    = 1000, /* Default timeout of 1 second */
0507 };
0508 
0509 static struct resource orion_i2c_resources[2];
0510 
0511 static struct platform_device orion_i2c = {
0512     .name       = MV64XXX_I2C_CTLR_NAME,
0513     .id     = 0,
0514     .dev        = {
0515         .platform_data  = &orion_i2c_pdata,
0516     },
0517 };
0518 
0519 static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = {
0520     .freq_n     = 3,
0521     .timeout    = 1000, /* Default timeout of 1 second */
0522 };
0523 
0524 static struct resource orion_i2c_1_resources[2];
0525 
0526 static struct platform_device orion_i2c_1 = {
0527     .name       = MV64XXX_I2C_CTLR_NAME,
0528     .id     = 1,
0529     .dev        = {
0530         .platform_data  = &orion_i2c_1_pdata,
0531     },
0532 };
0533 
0534 void __init orion_i2c_init(unsigned long mapbase,
0535                unsigned long irq,
0536                unsigned long freq_m)
0537 {
0538     orion_i2c_pdata.freq_m = freq_m;
0539     fill_resources_irq(&orion_i2c, orion_i2c_resources, mapbase,
0540                SZ_32 - 1, irq);
0541     platform_device_register(&orion_i2c);
0542 }
0543 
0544 void __init orion_i2c_1_init(unsigned long mapbase,
0545                  unsigned long irq,
0546                  unsigned long freq_m)
0547 {
0548     orion_i2c_1_pdata.freq_m = freq_m;
0549     fill_resources_irq(&orion_i2c_1, orion_i2c_1_resources, mapbase,
0550                SZ_32 - 1, irq);
0551     platform_device_register(&orion_i2c_1);
0552 }
0553 
0554 /*****************************************************************************
0555  * SPI
0556  ****************************************************************************/
0557 static struct resource orion_spi_resources;
0558 
0559 static struct platform_device orion_spi = {
0560     .name       = "orion_spi",
0561     .id     = 0,
0562 };
0563 
0564 static struct resource orion_spi_1_resources;
0565 
0566 static struct platform_device orion_spi_1 = {
0567     .name       = "orion_spi",
0568     .id     = 1,
0569 };
0570 
0571 /* Note: The SPI silicon core does have interrupts. However the
0572  * current Linux software driver does not use interrupts. */
0573 
0574 void __init orion_spi_init(unsigned long mapbase)
0575 {
0576     fill_resources(&orion_spi, &orion_spi_resources,
0577                mapbase, SZ_512 - 1);
0578     platform_device_register(&orion_spi);
0579 }
0580 
0581 void __init orion_spi_1_init(unsigned long mapbase)
0582 {
0583     fill_resources(&orion_spi_1, &orion_spi_1_resources,
0584                mapbase, SZ_512 - 1);
0585     platform_device_register(&orion_spi_1);
0586 }
0587 
0588 /*****************************************************************************
0589  * XOR
0590  ****************************************************************************/
0591 static u64 orion_xor_dmamask = DMA_BIT_MASK(32);
0592 
0593 /*****************************************************************************
0594  * XOR0
0595  ****************************************************************************/
0596 static struct resource orion_xor0_shared_resources[] = {
0597     {
0598         .name   = "xor 0 low",
0599         .flags  = IORESOURCE_MEM,
0600     }, {
0601         .name   = "xor 0 high",
0602         .flags  = IORESOURCE_MEM,
0603     }, {
0604         .name   = "irq channel 0",
0605         .flags  = IORESOURCE_IRQ,
0606     }, {
0607         .name   = "irq channel 1",
0608         .flags  = IORESOURCE_IRQ,
0609     },
0610 };
0611 
0612 static struct mv_xor_channel_data orion_xor0_channels_data[2];
0613 
0614 static struct mv_xor_platform_data orion_xor0_pdata = {
0615     .channels = orion_xor0_channels_data,
0616 };
0617 
0618 static struct platform_device orion_xor0_shared = {
0619     .name       = MV_XOR_NAME,
0620     .id     = 0,
0621     .num_resources  = ARRAY_SIZE(orion_xor0_shared_resources),
0622     .resource   = orion_xor0_shared_resources,
0623     .dev            = {
0624         .dma_mask               = &orion_xor_dmamask,
0625         .coherent_dma_mask      = DMA_BIT_MASK(32),
0626         .platform_data          = &orion_xor0_pdata,
0627     },
0628 };
0629 
0630 void __init orion_xor0_init(unsigned long mapbase_low,
0631                 unsigned long mapbase_high,
0632                 unsigned long irq_0,
0633                 unsigned long irq_1)
0634 {
0635     orion_xor0_shared_resources[0].start = mapbase_low;
0636     orion_xor0_shared_resources[0].end = mapbase_low + 0xff;
0637     orion_xor0_shared_resources[1].start = mapbase_high;
0638     orion_xor0_shared_resources[1].end = mapbase_high + 0xff;
0639 
0640     orion_xor0_shared_resources[2].start = irq_0;
0641     orion_xor0_shared_resources[2].end = irq_0;
0642     orion_xor0_shared_resources[3].start = irq_1;
0643     orion_xor0_shared_resources[3].end = irq_1;
0644 
0645     dma_cap_set(DMA_MEMCPY, orion_xor0_channels_data[0].cap_mask);
0646     dma_cap_set(DMA_XOR, orion_xor0_channels_data[0].cap_mask);
0647 
0648     dma_cap_set(DMA_MEMCPY, orion_xor0_channels_data[1].cap_mask);
0649     dma_cap_set(DMA_XOR, orion_xor0_channels_data[1].cap_mask);
0650 
0651     platform_device_register(&orion_xor0_shared);
0652 }
0653 
0654 /*****************************************************************************
0655  * XOR1
0656  ****************************************************************************/
0657 static struct resource orion_xor1_shared_resources[] = {
0658     {
0659         .name   = "xor 1 low",
0660         .flags  = IORESOURCE_MEM,
0661     }, {
0662         .name   = "xor 1 high",
0663         .flags  = IORESOURCE_MEM,
0664     }, {
0665         .name   = "irq channel 0",
0666         .flags  = IORESOURCE_IRQ,
0667     }, {
0668         .name   = "irq channel 1",
0669         .flags  = IORESOURCE_IRQ,
0670     },
0671 };
0672 
0673 static struct mv_xor_channel_data orion_xor1_channels_data[2];
0674 
0675 static struct mv_xor_platform_data orion_xor1_pdata = {
0676     .channels = orion_xor1_channels_data,
0677 };
0678 
0679 static struct platform_device orion_xor1_shared = {
0680     .name       = MV_XOR_NAME,
0681     .id     = 1,
0682     .num_resources  = ARRAY_SIZE(orion_xor1_shared_resources),
0683     .resource   = orion_xor1_shared_resources,
0684     .dev            = {
0685         .dma_mask               = &orion_xor_dmamask,
0686         .coherent_dma_mask      = DMA_BIT_MASK(32),
0687         .platform_data          = &orion_xor1_pdata,
0688     },
0689 };
0690 
0691 void __init orion_xor1_init(unsigned long mapbase_low,
0692                 unsigned long mapbase_high,
0693                 unsigned long irq_0,
0694                 unsigned long irq_1)
0695 {
0696     orion_xor1_shared_resources[0].start = mapbase_low;
0697     orion_xor1_shared_resources[0].end = mapbase_low + 0xff;
0698     orion_xor1_shared_resources[1].start = mapbase_high;
0699     orion_xor1_shared_resources[1].end = mapbase_high + 0xff;
0700 
0701     orion_xor1_shared_resources[2].start = irq_0;
0702     orion_xor1_shared_resources[2].end = irq_0;
0703     orion_xor1_shared_resources[3].start = irq_1;
0704     orion_xor1_shared_resources[3].end = irq_1;
0705 
0706     dma_cap_set(DMA_MEMCPY, orion_xor1_channels_data[0].cap_mask);
0707     dma_cap_set(DMA_XOR, orion_xor1_channels_data[0].cap_mask);
0708 
0709     dma_cap_set(DMA_MEMCPY, orion_xor1_channels_data[1].cap_mask);
0710     dma_cap_set(DMA_XOR, orion_xor1_channels_data[1].cap_mask);
0711 
0712     platform_device_register(&orion_xor1_shared);
0713 }
0714 
0715 /*****************************************************************************
0716  * EHCI
0717  ****************************************************************************/
0718 static struct orion_ehci_data orion_ehci_data;
0719 static u64 ehci_dmamask = DMA_BIT_MASK(32);
0720 
0721 
0722 /*****************************************************************************
0723  * EHCI0
0724  ****************************************************************************/
0725 static struct resource orion_ehci_resources[2];
0726 
0727 static struct platform_device orion_ehci = {
0728     .name       = "orion-ehci",
0729     .id     = 0,
0730     .dev        = {
0731         .dma_mask       = &ehci_dmamask,
0732         .coherent_dma_mask  = DMA_BIT_MASK(32),
0733         .platform_data      = &orion_ehci_data,
0734     },
0735 };
0736 
0737 void __init orion_ehci_init(unsigned long mapbase,
0738                 unsigned long irq,
0739                 enum orion_ehci_phy_ver phy_version)
0740 {
0741     orion_ehci_data.phy_version = phy_version;
0742     fill_resources_irq(&orion_ehci, orion_ehci_resources, mapbase, SZ_4K - 1,
0743                irq);
0744 
0745     platform_device_register(&orion_ehci);
0746 }
0747 
0748 /*****************************************************************************
0749  * EHCI1
0750  ****************************************************************************/
0751 static struct resource orion_ehci_1_resources[2];
0752 
0753 static struct platform_device orion_ehci_1 = {
0754     .name       = "orion-ehci",
0755     .id     = 1,
0756     .dev        = {
0757         .dma_mask       = &ehci_dmamask,
0758         .coherent_dma_mask  = DMA_BIT_MASK(32),
0759         .platform_data      = &orion_ehci_data,
0760     },
0761 };
0762 
0763 void __init orion_ehci_1_init(unsigned long mapbase,
0764                   unsigned long irq)
0765 {
0766     fill_resources_irq(&orion_ehci_1, orion_ehci_1_resources,
0767                mapbase, SZ_4K - 1, irq);
0768 
0769     platform_device_register(&orion_ehci_1);
0770 }
0771 
0772 /*****************************************************************************
0773  * EHCI2
0774  ****************************************************************************/
0775 static struct resource orion_ehci_2_resources[2];
0776 
0777 static struct platform_device orion_ehci_2 = {
0778     .name       = "orion-ehci",
0779     .id     = 2,
0780     .dev        = {
0781         .dma_mask       = &ehci_dmamask,
0782         .coherent_dma_mask  = DMA_BIT_MASK(32),
0783         .platform_data      = &orion_ehci_data,
0784     },
0785 };
0786 
0787 void __init orion_ehci_2_init(unsigned long mapbase,
0788                   unsigned long irq)
0789 {
0790     fill_resources_irq(&orion_ehci_2, orion_ehci_2_resources,
0791                mapbase, SZ_4K - 1, irq);
0792 
0793     platform_device_register(&orion_ehci_2);
0794 }
0795 
0796 /*****************************************************************************
0797  * SATA
0798  ****************************************************************************/
0799 static struct resource orion_sata_resources[2] = {
0800     {
0801         .name   = "sata base",
0802     }, {
0803         .name   = "sata irq",
0804     },
0805 };
0806 
0807 static struct platform_device orion_sata = {
0808     .name       = "sata_mv",
0809     .id     = 0,
0810     .dev        = {
0811         .coherent_dma_mask  = DMA_BIT_MASK(32),
0812     },
0813 };
0814 
0815 void __init orion_sata_init(struct mv_sata_platform_data *sata_data,
0816                 unsigned long mapbase,
0817                 unsigned long irq)
0818 {
0819     orion_sata.dev.platform_data = sata_data;
0820     fill_resources_irq(&orion_sata, orion_sata_resources,
0821                mapbase, 0x5000 - 1, irq);
0822 
0823     platform_device_register(&orion_sata);
0824 }
0825 
0826 /*****************************************************************************
0827  * Cryptographic Engines and Security Accelerator (CESA)
0828  ****************************************************************************/
0829 static struct resource orion_crypto_resources[] = {
0830     {
0831         .name   = "regs",
0832     }, {
0833         .name   = "crypto interrupt",
0834     }, {
0835         .name   = "sram",
0836         .flags  = IORESOURCE_MEM,
0837     },
0838 };
0839 
0840 static struct platform_device orion_crypto = {
0841     .name           = "mv_crypto",
0842     .id             = -1,
0843 };
0844 
0845 void __init orion_crypto_init(unsigned long mapbase,
0846                   unsigned long srambase,
0847                   unsigned long sram_size,
0848                   unsigned long irq)
0849 {
0850     fill_resources_irq(&orion_crypto, orion_crypto_resources,
0851                mapbase, 0xffff, irq);
0852     orion_crypto.num_resources = 3;
0853     orion_crypto_resources[2].start = srambase;
0854     orion_crypto_resources[2].end = srambase + sram_size - 1;
0855 
0856     platform_device_register(&orion_crypto);
0857 }