18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 38c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 48c2ecf20Sopenharmony_ci * for more details. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> 78c2ecf20Sopenharmony_ci * Copyright (C) 2012 Kevin Cernekee <cernekee@gmail.com> 88c2ecf20Sopenharmony_ci * Copyright (C) 2012 Broadcom Corporation 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/init.h> 128c2ecf20Sopenharmony_ci#include <linux/kernel.h> 138c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 148c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h> 158c2ecf20Sopenharmony_ci#include <bcm63xx_cpu.h> 168c2ecf20Sopenharmony_ci#include <bcm63xx_dev_usb_usbd.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define NUM_MMIO 2 198c2ecf20Sopenharmony_ci#define NUM_IRQ 7 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistatic struct resource usbd_resources[NUM_MMIO + NUM_IRQ]; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistatic u64 usbd_dmamask = DMA_BIT_MASK(32); 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_cistatic struct platform_device bcm63xx_usbd_device = { 268c2ecf20Sopenharmony_ci .name = "bcm63xx_udc", 278c2ecf20Sopenharmony_ci .id = -1, 288c2ecf20Sopenharmony_ci .num_resources = ARRAY_SIZE(usbd_resources), 298c2ecf20Sopenharmony_ci .resource = usbd_resources, 308c2ecf20Sopenharmony_ci .dev = { 318c2ecf20Sopenharmony_ci .dma_mask = &usbd_dmamask, 328c2ecf20Sopenharmony_ci .coherent_dma_mask = DMA_BIT_MASK(32), 338c2ecf20Sopenharmony_ci }, 348c2ecf20Sopenharmony_ci}; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ciint __init bcm63xx_usbd_register(const struct bcm63xx_usbd_platform_data *pd) 378c2ecf20Sopenharmony_ci{ 388c2ecf20Sopenharmony_ci const int irq_list[NUM_IRQ] = { IRQ_USBD, 398c2ecf20Sopenharmony_ci IRQ_USBD_RXDMA0, IRQ_USBD_TXDMA0, 408c2ecf20Sopenharmony_ci IRQ_USBD_RXDMA1, IRQ_USBD_TXDMA1, 418c2ecf20Sopenharmony_ci IRQ_USBD_RXDMA2, IRQ_USBD_TXDMA2 }; 428c2ecf20Sopenharmony_ci int i; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci if (!BCMCPU_IS_6328() && !BCMCPU_IS_6368()) 458c2ecf20Sopenharmony_ci return 0; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci usbd_resources[0].start = bcm63xx_regset_address(RSET_USBD); 488c2ecf20Sopenharmony_ci usbd_resources[0].end = usbd_resources[0].start + RSET_USBD_SIZE - 1; 498c2ecf20Sopenharmony_ci usbd_resources[0].flags = IORESOURCE_MEM; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci usbd_resources[1].start = bcm63xx_regset_address(RSET_USBDMA); 528c2ecf20Sopenharmony_ci usbd_resources[1].end = usbd_resources[1].start + RSET_USBDMA_SIZE - 1; 538c2ecf20Sopenharmony_ci usbd_resources[1].flags = IORESOURCE_MEM; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci for (i = 0; i < NUM_IRQ; i++) { 568c2ecf20Sopenharmony_ci struct resource *r = &usbd_resources[NUM_MMIO + i]; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci r->start = r->end = bcm63xx_get_irq_number(irq_list[i]); 598c2ecf20Sopenharmony_ci r->flags = IORESOURCE_IRQ; 608c2ecf20Sopenharmony_ci } 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci platform_device_add_data(&bcm63xx_usbd_device, pd, sizeof(*pd)); 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci return platform_device_register(&bcm63xx_usbd_device); 658c2ecf20Sopenharmony_ci} 66