Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * License.  See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Copyright (C) 2012 Kevin Cernekee <cernekee@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * Copyright (C) 2012 Broadcom Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/dma-mapping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <bcm63xx_cpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <bcm63xx_dev_usb_usbd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define NUM_MMIO		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define NUM_IRQ			7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static struct resource usbd_resources[NUM_MMIO + NUM_IRQ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static u64 usbd_dmamask = DMA_BIT_MASK(32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static struct platform_device bcm63xx_usbd_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	.name		= "bcm63xx_udc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	.num_resources	= ARRAY_SIZE(usbd_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	.resource	= usbd_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		.dma_mask		= &usbd_dmamask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		.coherent_dma_mask	= DMA_BIT_MASK(32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int __init bcm63xx_usbd_register(const struct bcm63xx_usbd_platform_data *pd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	const int irq_list[NUM_IRQ] = { IRQ_USBD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		IRQ_USBD_RXDMA0, IRQ_USBD_TXDMA0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		IRQ_USBD_RXDMA1, IRQ_USBD_TXDMA1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		IRQ_USBD_RXDMA2, IRQ_USBD_TXDMA2 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	if (!BCMCPU_IS_6328() && !BCMCPU_IS_6368())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	usbd_resources[0].start = bcm63xx_regset_address(RSET_USBD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	usbd_resources[0].end = usbd_resources[0].start + RSET_USBD_SIZE - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	usbd_resources[0].flags = IORESOURCE_MEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	usbd_resources[1].start = bcm63xx_regset_address(RSET_USBDMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	usbd_resources[1].end = usbd_resources[1].start + RSET_USBDMA_SIZE - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	usbd_resources[1].flags = IORESOURCE_MEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	for (i = 0; i < NUM_IRQ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		struct resource *r = &usbd_resources[NUM_MMIO + i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		r->start = r->end = bcm63xx_get_irq_number(irq_list[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 		r->flags = IORESOURCE_IRQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	platform_device_add_data(&bcm63xx_usbd_device, pd, sizeof(*pd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	return platform_device_register(&bcm63xx_usbd_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }