18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * PLX NET2272 high/full speed USB device controller 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2005-2006 PLX Technology, Inc. 68c2ecf20Sopenharmony_ci * Copyright (C) 2006-2011 Analog Devices, Inc. 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef __NET2272_H__ 108c2ecf20Sopenharmony_ci#define __NET2272_H__ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci/* Main Registers */ 138c2ecf20Sopenharmony_ci#define REGADDRPTR 0x00 148c2ecf20Sopenharmony_ci#define REGDATA 0x01 158c2ecf20Sopenharmony_ci#define IRQSTAT0 0x02 168c2ecf20Sopenharmony_ci#define ENDPOINT_0_INTERRUPT 0 178c2ecf20Sopenharmony_ci#define ENDPOINT_A_INTERRUPT 1 188c2ecf20Sopenharmony_ci#define ENDPOINT_B_INTERRUPT 2 198c2ecf20Sopenharmony_ci#define ENDPOINT_C_INTERRUPT 3 208c2ecf20Sopenharmony_ci#define VIRTUALIZED_ENDPOINT_INTERRUPT 4 218c2ecf20Sopenharmony_ci#define SETUP_PACKET_INTERRUPT 5 228c2ecf20Sopenharmony_ci#define DMA_DONE_INTERRUPT 6 238c2ecf20Sopenharmony_ci#define SOF_INTERRUPT 7 248c2ecf20Sopenharmony_ci#define IRQSTAT1 0x03 258c2ecf20Sopenharmony_ci#define CONTROL_STATUS_INTERRUPT 1 268c2ecf20Sopenharmony_ci#define VBUS_INTERRUPT 2 278c2ecf20Sopenharmony_ci#define SUSPEND_REQUEST_INTERRUPT 3 288c2ecf20Sopenharmony_ci#define SUSPEND_REQUEST_CHANGE_INTERRUPT 4 298c2ecf20Sopenharmony_ci#define RESUME_INTERRUPT 5 308c2ecf20Sopenharmony_ci#define ROOT_PORT_RESET_INTERRUPT 6 318c2ecf20Sopenharmony_ci#define RESET_STATUS 7 328c2ecf20Sopenharmony_ci#define PAGESEL 0x04 338c2ecf20Sopenharmony_ci#define DMAREQ 0x1c 348c2ecf20Sopenharmony_ci#define DMA_ENDPOINT_SELECT 0 358c2ecf20Sopenharmony_ci#define DREQ_POLARITY 1 368c2ecf20Sopenharmony_ci#define DACK_POLARITY 2 378c2ecf20Sopenharmony_ci#define EOT_POLARITY 3 388c2ecf20Sopenharmony_ci#define DMA_CONTROL_DACK 4 398c2ecf20Sopenharmony_ci#define DMA_REQUEST_ENABLE 5 408c2ecf20Sopenharmony_ci#define DMA_REQUEST 6 418c2ecf20Sopenharmony_ci#define DMA_BUFFER_VALID 7 428c2ecf20Sopenharmony_ci#define SCRATCH 0x1d 438c2ecf20Sopenharmony_ci#define IRQENB0 0x20 448c2ecf20Sopenharmony_ci#define ENDPOINT_0_INTERRUPT_ENABLE 0 458c2ecf20Sopenharmony_ci#define ENDPOINT_A_INTERRUPT_ENABLE 1 468c2ecf20Sopenharmony_ci#define ENDPOINT_B_INTERRUPT_ENABLE 2 478c2ecf20Sopenharmony_ci#define ENDPOINT_C_INTERRUPT_ENABLE 3 488c2ecf20Sopenharmony_ci#define VIRTUALIZED_ENDPOINT_INTERRUPT_ENABLE 4 498c2ecf20Sopenharmony_ci#define SETUP_PACKET_INTERRUPT_ENABLE 5 508c2ecf20Sopenharmony_ci#define DMA_DONE_INTERRUPT_ENABLE 6 518c2ecf20Sopenharmony_ci#define SOF_INTERRUPT_ENABLE 7 528c2ecf20Sopenharmony_ci#define IRQENB1 0x21 538c2ecf20Sopenharmony_ci#define VBUS_INTERRUPT_ENABLE 2 548c2ecf20Sopenharmony_ci#define SUSPEND_REQUEST_INTERRUPT_ENABLE 3 558c2ecf20Sopenharmony_ci#define SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE 4 568c2ecf20Sopenharmony_ci#define RESUME_INTERRUPT_ENABLE 5 578c2ecf20Sopenharmony_ci#define ROOT_PORT_RESET_INTERRUPT_ENABLE 6 588c2ecf20Sopenharmony_ci#define LOCCTL 0x22 598c2ecf20Sopenharmony_ci#define DATA_WIDTH 0 608c2ecf20Sopenharmony_ci#define LOCAL_CLOCK_OUTPUT 1 618c2ecf20Sopenharmony_ci#define LOCAL_CLOCK_OUTPUT_OFF 0 628c2ecf20Sopenharmony_ci#define LOCAL_CLOCK_OUTPUT_3_75MHZ 1 638c2ecf20Sopenharmony_ci#define LOCAL_CLOCK_OUTPUT_7_5MHZ 2 648c2ecf20Sopenharmony_ci#define LOCAL_CLOCK_OUTPUT_15MHZ 3 658c2ecf20Sopenharmony_ci#define LOCAL_CLOCK_OUTPUT_30MHZ 4 668c2ecf20Sopenharmony_ci#define LOCAL_CLOCK_OUTPUT_60MHZ 5 678c2ecf20Sopenharmony_ci#define DMA_SPLIT_BUS_MODE 4 688c2ecf20Sopenharmony_ci#define BYTE_SWAP 5 698c2ecf20Sopenharmony_ci#define BUFFER_CONFIGURATION 6 708c2ecf20Sopenharmony_ci#define BUFFER_CONFIGURATION_EPA512_EPB512 0 718c2ecf20Sopenharmony_ci#define BUFFER_CONFIGURATION_EPA1024_EPB512 1 728c2ecf20Sopenharmony_ci#define BUFFER_CONFIGURATION_EPA1024_EPB1024 2 738c2ecf20Sopenharmony_ci#define BUFFER_CONFIGURATION_EPA1024DB 3 748c2ecf20Sopenharmony_ci#define CHIPREV_LEGACY 0x23 758c2ecf20Sopenharmony_ci#define NET2270_LEGACY_REV 0x40 768c2ecf20Sopenharmony_ci#define LOCCTL1 0x24 778c2ecf20Sopenharmony_ci#define DMA_MODE 0 788c2ecf20Sopenharmony_ci#define SLOW_DREQ 0 798c2ecf20Sopenharmony_ci#define FAST_DREQ 1 808c2ecf20Sopenharmony_ci#define BURST_MODE 2 818c2ecf20Sopenharmony_ci#define DMA_DACK_ENABLE 2 828c2ecf20Sopenharmony_ci#define CHIPREV_2272 0x25 838c2ecf20Sopenharmony_ci#define CHIPREV_NET2272_R1 0x10 848c2ecf20Sopenharmony_ci#define CHIPREV_NET2272_R1A 0x11 858c2ecf20Sopenharmony_ci/* USB Registers */ 868c2ecf20Sopenharmony_ci#define USBCTL0 0x18 878c2ecf20Sopenharmony_ci#define IO_WAKEUP_ENABLE 1 888c2ecf20Sopenharmony_ci#define USB_DETECT_ENABLE 3 898c2ecf20Sopenharmony_ci#define USB_ROOT_PORT_WAKEUP_ENABLE 5 908c2ecf20Sopenharmony_ci#define USBCTL1 0x19 918c2ecf20Sopenharmony_ci#define VBUS_PIN 0 928c2ecf20Sopenharmony_ci#define USB_FULL_SPEED 1 938c2ecf20Sopenharmony_ci#define USB_HIGH_SPEED 2 948c2ecf20Sopenharmony_ci#define GENERATE_RESUME 3 958c2ecf20Sopenharmony_ci#define VIRTUAL_ENDPOINT_ENABLE 4 968c2ecf20Sopenharmony_ci#define FRAME0 0x1a 978c2ecf20Sopenharmony_ci#define FRAME1 0x1b 988c2ecf20Sopenharmony_ci#define OURADDR 0x30 998c2ecf20Sopenharmony_ci#define FORCE_IMMEDIATE 7 1008c2ecf20Sopenharmony_ci#define USBDIAG 0x31 1018c2ecf20Sopenharmony_ci#define FORCE_TRANSMIT_CRC_ERROR 0 1028c2ecf20Sopenharmony_ci#define PREVENT_TRANSMIT_BIT_STUFF 1 1038c2ecf20Sopenharmony_ci#define FORCE_RECEIVE_ERROR 2 1048c2ecf20Sopenharmony_ci#define FAST_TIMES 4 1058c2ecf20Sopenharmony_ci#define USBTEST 0x32 1068c2ecf20Sopenharmony_ci#define TEST_MODE_SELECT 0 1078c2ecf20Sopenharmony_ci#define NORMAL_OPERATION 0 1088c2ecf20Sopenharmony_ci#define XCVRDIAG 0x33 1098c2ecf20Sopenharmony_ci#define FORCE_FULL_SPEED 2 1108c2ecf20Sopenharmony_ci#define FORCE_HIGH_SPEED 3 1118c2ecf20Sopenharmony_ci#define OPMODE 4 1128c2ecf20Sopenharmony_ci#define NORMAL_OPERATION 0 1138c2ecf20Sopenharmony_ci#define NON_DRIVING 1 1148c2ecf20Sopenharmony_ci#define DISABLE_BITSTUFF_AND_NRZI_ENCODE 2 1158c2ecf20Sopenharmony_ci#define LINESTATE 6 1168c2ecf20Sopenharmony_ci#define SE0_STATE 0 1178c2ecf20Sopenharmony_ci#define J_STATE 1 1188c2ecf20Sopenharmony_ci#define K_STATE 2 1198c2ecf20Sopenharmony_ci#define SE1_STATE 3 1208c2ecf20Sopenharmony_ci#define VIRTOUT0 0x34 1218c2ecf20Sopenharmony_ci#define VIRTOUT1 0x35 1228c2ecf20Sopenharmony_ci#define VIRTIN0 0x36 1238c2ecf20Sopenharmony_ci#define VIRTIN1 0x37 1248c2ecf20Sopenharmony_ci#define SETUP0 0x40 1258c2ecf20Sopenharmony_ci#define SETUP1 0x41 1268c2ecf20Sopenharmony_ci#define SETUP2 0x42 1278c2ecf20Sopenharmony_ci#define SETUP3 0x43 1288c2ecf20Sopenharmony_ci#define SETUP4 0x44 1298c2ecf20Sopenharmony_ci#define SETUP5 0x45 1308c2ecf20Sopenharmony_ci#define SETUP6 0x46 1318c2ecf20Sopenharmony_ci#define SETUP7 0x47 1328c2ecf20Sopenharmony_ci/* Endpoint Registers (Paged via PAGESEL) */ 1338c2ecf20Sopenharmony_ci#define EP_DATA 0x05 1348c2ecf20Sopenharmony_ci#define EP_STAT0 0x06 1358c2ecf20Sopenharmony_ci#define DATA_IN_TOKEN_INTERRUPT 0 1368c2ecf20Sopenharmony_ci#define DATA_OUT_TOKEN_INTERRUPT 1 1378c2ecf20Sopenharmony_ci#define DATA_PACKET_TRANSMITTED_INTERRUPT 2 1388c2ecf20Sopenharmony_ci#define DATA_PACKET_RECEIVED_INTERRUPT 3 1398c2ecf20Sopenharmony_ci#define SHORT_PACKET_TRANSFERRED_INTERRUPT 4 1408c2ecf20Sopenharmony_ci#define NAK_OUT_PACKETS 5 1418c2ecf20Sopenharmony_ci#define BUFFER_EMPTY 6 1428c2ecf20Sopenharmony_ci#define BUFFER_FULL 7 1438c2ecf20Sopenharmony_ci#define EP_STAT1 0x07 1448c2ecf20Sopenharmony_ci#define TIMEOUT 0 1458c2ecf20Sopenharmony_ci#define USB_OUT_ACK_SENT 1 1468c2ecf20Sopenharmony_ci#define USB_OUT_NAK_SENT 2 1478c2ecf20Sopenharmony_ci#define USB_IN_ACK_RCVD 3 1488c2ecf20Sopenharmony_ci#define USB_IN_NAK_SENT 4 1498c2ecf20Sopenharmony_ci#define USB_STALL_SENT 5 1508c2ecf20Sopenharmony_ci#define LOCAL_OUT_ZLP 6 1518c2ecf20Sopenharmony_ci#define BUFFER_FLUSH 7 1528c2ecf20Sopenharmony_ci#define EP_TRANSFER0 0x08 1538c2ecf20Sopenharmony_ci#define EP_TRANSFER1 0x09 1548c2ecf20Sopenharmony_ci#define EP_TRANSFER2 0x0a 1558c2ecf20Sopenharmony_ci#define EP_IRQENB 0x0b 1568c2ecf20Sopenharmony_ci#define DATA_IN_TOKEN_INTERRUPT_ENABLE 0 1578c2ecf20Sopenharmony_ci#define DATA_OUT_TOKEN_INTERRUPT_ENABLE 1 1588c2ecf20Sopenharmony_ci#define DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE 2 1598c2ecf20Sopenharmony_ci#define DATA_PACKET_RECEIVED_INTERRUPT_ENABLE 3 1608c2ecf20Sopenharmony_ci#define SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE 4 1618c2ecf20Sopenharmony_ci#define EP_AVAIL0 0x0c 1628c2ecf20Sopenharmony_ci#define EP_AVAIL1 0x0d 1638c2ecf20Sopenharmony_ci#define EP_RSPCLR 0x0e 1648c2ecf20Sopenharmony_ci#define EP_RSPSET 0x0f 1658c2ecf20Sopenharmony_ci#define ENDPOINT_HALT 0 1668c2ecf20Sopenharmony_ci#define ENDPOINT_TOGGLE 1 1678c2ecf20Sopenharmony_ci#define NAK_OUT_PACKETS_MODE 2 1688c2ecf20Sopenharmony_ci#define CONTROL_STATUS_PHASE_HANDSHAKE 3 1698c2ecf20Sopenharmony_ci#define INTERRUPT_MODE 4 1708c2ecf20Sopenharmony_ci#define AUTOVALIDATE 5 1718c2ecf20Sopenharmony_ci#define HIDE_STATUS_PHASE 6 1728c2ecf20Sopenharmony_ci#define ALT_NAK_OUT_PACKETS 7 1738c2ecf20Sopenharmony_ci#define EP_MAXPKT0 0x28 1748c2ecf20Sopenharmony_ci#define EP_MAXPKT1 0x29 1758c2ecf20Sopenharmony_ci#define ADDITIONAL_TRANSACTION_OPPORTUNITIES 3 1768c2ecf20Sopenharmony_ci#define NONE_ADDITIONAL_TRANSACTION 0 1778c2ecf20Sopenharmony_ci#define ONE_ADDITIONAL_TRANSACTION 1 1788c2ecf20Sopenharmony_ci#define TWO_ADDITIONAL_TRANSACTION 2 1798c2ecf20Sopenharmony_ci#define EP_CFG 0x2a 1808c2ecf20Sopenharmony_ci#define ENDPOINT_NUMBER 0 1818c2ecf20Sopenharmony_ci#define ENDPOINT_DIRECTION 4 1828c2ecf20Sopenharmony_ci#define ENDPOINT_TYPE 5 1838c2ecf20Sopenharmony_ci#define ENDPOINT_ENABLE 7 1848c2ecf20Sopenharmony_ci#define EP_HBW 0x2b 1858c2ecf20Sopenharmony_ci#define HIGH_BANDWIDTH_OUT_TRANSACTION_PID 0 1868c2ecf20Sopenharmony_ci#define DATA0_PID 0 1878c2ecf20Sopenharmony_ci#define DATA1_PID 1 1888c2ecf20Sopenharmony_ci#define DATA2_PID 2 1898c2ecf20Sopenharmony_ci#define MDATA_PID 3 1908c2ecf20Sopenharmony_ci#define EP_BUFF_STATES 0x2c 1918c2ecf20Sopenharmony_ci#define BUFFER_A_STATE 0 1928c2ecf20Sopenharmony_ci#define BUFFER_B_STATE 2 1938c2ecf20Sopenharmony_ci#define BUFF_FREE 0 1948c2ecf20Sopenharmony_ci#define BUFF_VALID 1 1958c2ecf20Sopenharmony_ci#define BUFF_LCL 2 1968c2ecf20Sopenharmony_ci#define BUFF_USB 3 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci/*---------------------------------------------------------------------------*/ 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_RDK1 0x9054 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci/* PCI-RDK EPLD Registers */ 2038c2ecf20Sopenharmony_ci#define RDK_EPLD_IO_REGISTER1 0x00000000 2048c2ecf20Sopenharmony_ci#define RDK_EPLD_USB_RESET 0 2058c2ecf20Sopenharmony_ci#define RDK_EPLD_USB_POWERDOWN 1 2068c2ecf20Sopenharmony_ci#define RDK_EPLD_USB_WAKEUP 2 2078c2ecf20Sopenharmony_ci#define RDK_EPLD_USB_EOT 3 2088c2ecf20Sopenharmony_ci#define RDK_EPLD_DPPULL 4 2098c2ecf20Sopenharmony_ci#define RDK_EPLD_IO_REGISTER2 0x00000004 2108c2ecf20Sopenharmony_ci#define RDK_EPLD_BUSWIDTH 0 2118c2ecf20Sopenharmony_ci#define RDK_EPLD_USER 2 2128c2ecf20Sopenharmony_ci#define RDK_EPLD_RESET_INTERRUPT_ENABLE 3 2138c2ecf20Sopenharmony_ci#define RDK_EPLD_DMA_TIMEOUT_ENABLE 4 2148c2ecf20Sopenharmony_ci#define RDK_EPLD_STATUS_REGISTER 0x00000008 2158c2ecf20Sopenharmony_ci#define RDK_EPLD_USB_LRESET 0 2168c2ecf20Sopenharmony_ci#define RDK_EPLD_REVISION_REGISTER 0x0000000c 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci/* PCI-RDK PLX 9054 Registers */ 2198c2ecf20Sopenharmony_ci#define INTCSR 0x68 2208c2ecf20Sopenharmony_ci#define PCI_INTERRUPT_ENABLE 8 2218c2ecf20Sopenharmony_ci#define LOCAL_INTERRUPT_INPUT_ENABLE 11 2228c2ecf20Sopenharmony_ci#define LOCAL_INPUT_INTERRUPT_ACTIVE 15 2238c2ecf20Sopenharmony_ci#define LOCAL_DMA_CHANNEL_0_INTERRUPT_ENABLE 18 2248c2ecf20Sopenharmony_ci#define LOCAL_DMA_CHANNEL_1_INTERRUPT_ENABLE 19 2258c2ecf20Sopenharmony_ci#define DMA_CHANNEL_0_INTERRUPT_ACTIVE 21 2268c2ecf20Sopenharmony_ci#define DMA_CHANNEL_1_INTERRUPT_ACTIVE 22 2278c2ecf20Sopenharmony_ci#define CNTRL 0x6C 2288c2ecf20Sopenharmony_ci#define RELOAD_CONFIGURATION_REGISTERS 29 2298c2ecf20Sopenharmony_ci#define PCI_ADAPTER_SOFTWARE_RESET 30 2308c2ecf20Sopenharmony_ci#define DMAMODE0 0x80 2318c2ecf20Sopenharmony_ci#define LOCAL_BUS_WIDTH 0 2328c2ecf20Sopenharmony_ci#define INTERNAL_WAIT_STATES 2 2338c2ecf20Sopenharmony_ci#define TA_READY_INPUT_ENABLE 6 2348c2ecf20Sopenharmony_ci#define LOCAL_BURST_ENABLE 8 2358c2ecf20Sopenharmony_ci#define SCATTER_GATHER_MODE 9 2368c2ecf20Sopenharmony_ci#define DONE_INTERRUPT_ENABLE 10 2378c2ecf20Sopenharmony_ci#define LOCAL_ADDRESSING_MODE 11 2388c2ecf20Sopenharmony_ci#define DEMAND_MODE 12 2398c2ecf20Sopenharmony_ci#define DMA_EOT_ENABLE 14 2408c2ecf20Sopenharmony_ci#define FAST_SLOW_TERMINATE_MODE_SELECT 15 2418c2ecf20Sopenharmony_ci#define DMA_CHANNEL_INTERRUPT_SELECT 17 2428c2ecf20Sopenharmony_ci#define DMAPADR0 0x84 2438c2ecf20Sopenharmony_ci#define DMALADR0 0x88 2448c2ecf20Sopenharmony_ci#define DMASIZ0 0x8c 2458c2ecf20Sopenharmony_ci#define DMADPR0 0x90 2468c2ecf20Sopenharmony_ci#define DESCRIPTOR_LOCATION 0 2478c2ecf20Sopenharmony_ci#define END_OF_CHAIN 1 2488c2ecf20Sopenharmony_ci#define INTERRUPT_AFTER_TERMINAL_COUNT 2 2498c2ecf20Sopenharmony_ci#define DIRECTION_OF_TRANSFER 3 2508c2ecf20Sopenharmony_ci#define DMACSR0 0xa8 2518c2ecf20Sopenharmony_ci#define CHANNEL_ENABLE 0 2528c2ecf20Sopenharmony_ci#define CHANNEL_START 1 2538c2ecf20Sopenharmony_ci#define CHANNEL_ABORT 2 2548c2ecf20Sopenharmony_ci#define CHANNEL_CLEAR_INTERRUPT 3 2558c2ecf20Sopenharmony_ci#define CHANNEL_DONE 4 2568c2ecf20Sopenharmony_ci#define DMATHR 0xb0 2578c2ecf20Sopenharmony_ci#define LBRD1 0xf8 2588c2ecf20Sopenharmony_ci#define MEMORY_SPACE_LOCAL_BUS_WIDTH 0 2598c2ecf20Sopenharmony_ci#define W8_BIT 0 2608c2ecf20Sopenharmony_ci#define W16_BIT 1 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci/* Special OR'ing of INTCSR bits */ 2638c2ecf20Sopenharmony_ci#define LOCAL_INTERRUPT_TEST \ 2648c2ecf20Sopenharmony_ci ((1 << LOCAL_INPUT_INTERRUPT_ACTIVE) | \ 2658c2ecf20Sopenharmony_ci (1 << LOCAL_INTERRUPT_INPUT_ENABLE)) 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci#define DMA_CHANNEL_0_TEST \ 2688c2ecf20Sopenharmony_ci ((1 << DMA_CHANNEL_0_INTERRUPT_ACTIVE) | \ 2698c2ecf20Sopenharmony_ci (1 << LOCAL_DMA_CHANNEL_0_INTERRUPT_ENABLE)) 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci#define DMA_CHANNEL_1_TEST \ 2728c2ecf20Sopenharmony_ci ((1 << DMA_CHANNEL_1_INTERRUPT_ACTIVE) | \ 2738c2ecf20Sopenharmony_ci (1 << LOCAL_DMA_CHANNEL_1_INTERRUPT_ENABLE)) 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci/* EPLD Registers */ 2768c2ecf20Sopenharmony_ci#define RDK_EPLD_IO_REGISTER1 0x00000000 2778c2ecf20Sopenharmony_ci#define RDK_EPLD_USB_RESET 0 2788c2ecf20Sopenharmony_ci#define RDK_EPLD_USB_POWERDOWN 1 2798c2ecf20Sopenharmony_ci#define RDK_EPLD_USB_WAKEUP 2 2808c2ecf20Sopenharmony_ci#define RDK_EPLD_USB_EOT 3 2818c2ecf20Sopenharmony_ci#define RDK_EPLD_DPPULL 4 2828c2ecf20Sopenharmony_ci#define RDK_EPLD_IO_REGISTER2 0x00000004 2838c2ecf20Sopenharmony_ci#define RDK_EPLD_BUSWIDTH 0 2848c2ecf20Sopenharmony_ci#define RDK_EPLD_USER 2 2858c2ecf20Sopenharmony_ci#define RDK_EPLD_RESET_INTERRUPT_ENABLE 3 2868c2ecf20Sopenharmony_ci#define RDK_EPLD_DMA_TIMEOUT_ENABLE 4 2878c2ecf20Sopenharmony_ci#define RDK_EPLD_STATUS_REGISTER 0x00000008 2888c2ecf20Sopenharmony_ci#define RDK_EPLD_USB_LRESET 0 2898c2ecf20Sopenharmony_ci#define RDK_EPLD_REVISION_REGISTER 0x0000000c 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci#define EPLD_IO_CONTROL_REGISTER 0x400 2928c2ecf20Sopenharmony_ci#define NET2272_RESET 0 2938c2ecf20Sopenharmony_ci#define BUSWIDTH 1 2948c2ecf20Sopenharmony_ci#define MPX_MODE 3 2958c2ecf20Sopenharmony_ci#define USER 4 2968c2ecf20Sopenharmony_ci#define DMA_TIMEOUT_ENABLE 5 2978c2ecf20Sopenharmony_ci#define DMA_CTL_DACK 6 2988c2ecf20Sopenharmony_ci#define EPLD_DMA_ENABLE 7 2998c2ecf20Sopenharmony_ci#define EPLD_DMA_CONTROL_REGISTER 0x800 3008c2ecf20Sopenharmony_ci#define SPLIT_DMA_MODE 0 3018c2ecf20Sopenharmony_ci#define SPLIT_DMA_DIRECTION 1 3028c2ecf20Sopenharmony_ci#define SPLIT_DMA_ENABLE 2 3038c2ecf20Sopenharmony_ci#define SPLIT_DMA_INTERRUPT_ENABLE 3 3048c2ecf20Sopenharmony_ci#define SPLIT_DMA_INTERRUPT 4 3058c2ecf20Sopenharmony_ci#define EPLD_DMA_MODE 5 3068c2ecf20Sopenharmony_ci#define EPLD_DMA_CONTROLLER_ENABLE 7 3078c2ecf20Sopenharmony_ci#define SPLIT_DMA_ADDRESS_LOW 0xc00 3088c2ecf20Sopenharmony_ci#define SPLIT_DMA_ADDRESS_HIGH 0x1000 3098c2ecf20Sopenharmony_ci#define SPLIT_DMA_BYTE_COUNT_LOW 0x1400 3108c2ecf20Sopenharmony_ci#define SPLIT_DMA_BYTE_COUNT_HIGH 0x1800 3118c2ecf20Sopenharmony_ci#define EPLD_REVISION_REGISTER 0x1c00 3128c2ecf20Sopenharmony_ci#define SPLIT_DMA_RAM 0x4000 3138c2ecf20Sopenharmony_ci#define DMA_RAM_SIZE 0x1000 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci/*---------------------------------------------------------------------------*/ 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_RDK2 0x3272 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci/* PCI-RDK version 2 registers */ 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci/* Main Control Registers */ 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci#define RDK2_IRQENB 0x00 3248c2ecf20Sopenharmony_ci#define RDK2_IRQSTAT 0x04 3258c2ecf20Sopenharmony_ci#define PB7 23 3268c2ecf20Sopenharmony_ci#define PB6 22 3278c2ecf20Sopenharmony_ci#define PB5 21 3288c2ecf20Sopenharmony_ci#define PB4 20 3298c2ecf20Sopenharmony_ci#define PB3 19 3308c2ecf20Sopenharmony_ci#define PB2 18 3318c2ecf20Sopenharmony_ci#define PB1 17 3328c2ecf20Sopenharmony_ci#define PB0 16 3338c2ecf20Sopenharmony_ci#define GP3 23 3348c2ecf20Sopenharmony_ci#define GP2 23 3358c2ecf20Sopenharmony_ci#define GP1 23 3368c2ecf20Sopenharmony_ci#define GP0 23 3378c2ecf20Sopenharmony_ci#define DMA_RETRY_ABORT 6 3388c2ecf20Sopenharmony_ci#define DMA_PAUSE_DONE 5 3398c2ecf20Sopenharmony_ci#define DMA_ABORT_DONE 4 3408c2ecf20Sopenharmony_ci#define DMA_OUT_FIFO_TRANSFER_DONE 3 3418c2ecf20Sopenharmony_ci#define DMA_LOCAL_DONE 2 3428c2ecf20Sopenharmony_ci#define DMA_PCI_DONE 1 3438c2ecf20Sopenharmony_ci#define NET2272_PCI_IRQ 0 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ci#define RDK2_LOCCTLRDK 0x08 3468c2ecf20Sopenharmony_ci#define CHIP_RESET 3 3478c2ecf20Sopenharmony_ci#define SPLIT_DMA 2 3488c2ecf20Sopenharmony_ci#define MULTIPLEX_MODE 1 3498c2ecf20Sopenharmony_ci#define BUS_WIDTH 0 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci#define RDK2_GPIOCTL 0x10 3528c2ecf20Sopenharmony_ci#define GP3_OUT_ENABLE 7 3538c2ecf20Sopenharmony_ci#define GP2_OUT_ENABLE 6 3548c2ecf20Sopenharmony_ci#define GP1_OUT_ENABLE 5 3558c2ecf20Sopenharmony_ci#define GP0_OUT_ENABLE 4 3568c2ecf20Sopenharmony_ci#define GP3_DATA 3 3578c2ecf20Sopenharmony_ci#define GP2_DATA 2 3588c2ecf20Sopenharmony_ci#define GP1_DATA 1 3598c2ecf20Sopenharmony_ci#define GP0_DATA 0 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci#define RDK2_LEDSW 0x14 3628c2ecf20Sopenharmony_ci#define LED3 27 3638c2ecf20Sopenharmony_ci#define LED2 26 3648c2ecf20Sopenharmony_ci#define LED1 25 3658c2ecf20Sopenharmony_ci#define LED0 24 3668c2ecf20Sopenharmony_ci#define PBUTTON 16 3678c2ecf20Sopenharmony_ci#define DIPSW 0 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci#define RDK2_DIAG 0x18 3708c2ecf20Sopenharmony_ci#define RDK2_FAST_TIMES 2 3718c2ecf20Sopenharmony_ci#define FORCE_PCI_SERR 1 3728c2ecf20Sopenharmony_ci#define FORCE_PCI_INT 0 3738c2ecf20Sopenharmony_ci#define RDK2_FPGAREV 0x1C 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci/* Dma Control registers */ 3768c2ecf20Sopenharmony_ci#define RDK2_DMACTL 0x80 3778c2ecf20Sopenharmony_ci#define ADDR_HOLD 24 3788c2ecf20Sopenharmony_ci#define RETRY_COUNT 16 /* 23:16 */ 3798c2ecf20Sopenharmony_ci#define FIFO_THRESHOLD 11 /* 15:11 */ 3808c2ecf20Sopenharmony_ci#define MEM_WRITE_INVALIDATE 10 3818c2ecf20Sopenharmony_ci#define READ_MULTIPLE 9 3828c2ecf20Sopenharmony_ci#define READ_LINE 8 3838c2ecf20Sopenharmony_ci#define RDK2_DMA_MODE 6 /* 7:6 */ 3848c2ecf20Sopenharmony_ci#define CONTROL_DACK 5 3858c2ecf20Sopenharmony_ci#define EOT_ENABLE 4 3868c2ecf20Sopenharmony_ci#define EOT_POLARITY 3 3878c2ecf20Sopenharmony_ci#define DACK_POLARITY 2 3888c2ecf20Sopenharmony_ci#define DREQ_POLARITY 1 3898c2ecf20Sopenharmony_ci#define DMA_ENABLE 0 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci#define RDK2_DMASTAT 0x84 3928c2ecf20Sopenharmony_ci#define GATHER_COUNT 12 /* 14:12 */ 3938c2ecf20Sopenharmony_ci#define FIFO_COUNT 6 /* 11:6 */ 3948c2ecf20Sopenharmony_ci#define FIFO_FLUSH 5 3958c2ecf20Sopenharmony_ci#define FIFO_TRANSFER 4 3968c2ecf20Sopenharmony_ci#define PAUSE_DONE 3 3978c2ecf20Sopenharmony_ci#define ABORT_DONE 2 3988c2ecf20Sopenharmony_ci#define DMA_ABORT 1 3998c2ecf20Sopenharmony_ci#define DMA_START 0 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci#define RDK2_DMAPCICOUNT 0x88 4028c2ecf20Sopenharmony_ci#define DMA_DIRECTION 31 4038c2ecf20Sopenharmony_ci#define DMA_PCI_BYTE_COUNT 0 /* 0:23 */ 4048c2ecf20Sopenharmony_ci 4058c2ecf20Sopenharmony_ci#define RDK2_DMALOCCOUNT 0x8C /* 0:23 dma local byte count */ 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ci#define RDK2_DMAADDR 0x90 /* 2:31 PCI bus starting address */ 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_ci/*---------------------------------------------------------------------------*/ 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci#define REG_INDEXED_THRESHOLD (1 << 5) 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci/* DRIVER DATA STRUCTURES and UTILITIES */ 4148c2ecf20Sopenharmony_cistruct net2272_ep { 4158c2ecf20Sopenharmony_ci struct usb_ep ep; 4168c2ecf20Sopenharmony_ci struct net2272 *dev; 4178c2ecf20Sopenharmony_ci unsigned long irqs; 4188c2ecf20Sopenharmony_ci 4198c2ecf20Sopenharmony_ci /* analogous to a host-side qh */ 4208c2ecf20Sopenharmony_ci struct list_head queue; 4218c2ecf20Sopenharmony_ci const struct usb_endpoint_descriptor *desc; 4228c2ecf20Sopenharmony_ci unsigned num:8, 4238c2ecf20Sopenharmony_ci fifo_size:12, 4248c2ecf20Sopenharmony_ci stopped:1, 4258c2ecf20Sopenharmony_ci wedged:1, 4268c2ecf20Sopenharmony_ci is_in:1, 4278c2ecf20Sopenharmony_ci is_iso:1, 4288c2ecf20Sopenharmony_ci dma:1, 4298c2ecf20Sopenharmony_ci not_empty:1; 4308c2ecf20Sopenharmony_ci}; 4318c2ecf20Sopenharmony_ci 4328c2ecf20Sopenharmony_cistruct net2272 { 4338c2ecf20Sopenharmony_ci /* each device provides one gadget, several endpoints */ 4348c2ecf20Sopenharmony_ci struct usb_gadget gadget; 4358c2ecf20Sopenharmony_ci struct device *dev; 4368c2ecf20Sopenharmony_ci unsigned short dev_id; 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_ci spinlock_t lock; 4398c2ecf20Sopenharmony_ci struct net2272_ep ep[4]; 4408c2ecf20Sopenharmony_ci struct usb_gadget_driver *driver; 4418c2ecf20Sopenharmony_ci unsigned protocol_stall:1, 4428c2ecf20Sopenharmony_ci softconnect:1, 4438c2ecf20Sopenharmony_ci wakeup:1, 4448c2ecf20Sopenharmony_ci added:1, 4458c2ecf20Sopenharmony_ci dma_eot_polarity:1, 4468c2ecf20Sopenharmony_ci dma_dack_polarity:1, 4478c2ecf20Sopenharmony_ci dma_dreq_polarity:1, 4488c2ecf20Sopenharmony_ci dma_busy:1; 4498c2ecf20Sopenharmony_ci u16 chiprev; 4508c2ecf20Sopenharmony_ci u8 pagesel; 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci unsigned int irq; 4538c2ecf20Sopenharmony_ci unsigned short fifo_mode; 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci unsigned int base_shift; 4568c2ecf20Sopenharmony_ci u16 __iomem *base_addr; 4578c2ecf20Sopenharmony_ci union { 4588c2ecf20Sopenharmony_ci#ifdef CONFIG_USB_PCI 4598c2ecf20Sopenharmony_ci struct { 4608c2ecf20Sopenharmony_ci void __iomem *plx9054_base_addr; 4618c2ecf20Sopenharmony_ci void __iomem *epld_base_addr; 4628c2ecf20Sopenharmony_ci } rdk1; 4638c2ecf20Sopenharmony_ci struct { 4648c2ecf20Sopenharmony_ci /* Bar0, Bar1 is base_addr both mem-mapped */ 4658c2ecf20Sopenharmony_ci void __iomem *fpga_base_addr; 4668c2ecf20Sopenharmony_ci } rdk2; 4678c2ecf20Sopenharmony_ci#endif 4688c2ecf20Sopenharmony_ci }; 4698c2ecf20Sopenharmony_ci}; 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_cistatic void __iomem * 4728c2ecf20Sopenharmony_cinet2272_reg_addr(struct net2272 *dev, unsigned int reg) 4738c2ecf20Sopenharmony_ci{ 4748c2ecf20Sopenharmony_ci return dev->base_addr + (reg << dev->base_shift); 4758c2ecf20Sopenharmony_ci} 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_cistatic void 4788c2ecf20Sopenharmony_cinet2272_write(struct net2272 *dev, unsigned int reg, u8 value) 4798c2ecf20Sopenharmony_ci{ 4808c2ecf20Sopenharmony_ci if (reg >= REG_INDEXED_THRESHOLD) { 4818c2ecf20Sopenharmony_ci /* 4828c2ecf20Sopenharmony_ci * Indexed register; use REGADDRPTR/REGDATA 4838c2ecf20Sopenharmony_ci * - Save and restore REGADDRPTR. This prevents REGADDRPTR from 4848c2ecf20Sopenharmony_ci * changes between other code sections, but it is time consuming. 4858c2ecf20Sopenharmony_ci * - Performance tips: either do not save and restore REGADDRPTR (if it 4868c2ecf20Sopenharmony_ci * is safe) or do save/restore operations only in critical sections. 4878c2ecf20Sopenharmony_ci u8 tmp = readb(dev->base_addr + REGADDRPTR); 4888c2ecf20Sopenharmony_ci */ 4898c2ecf20Sopenharmony_ci writeb((u8)reg, net2272_reg_addr(dev, REGADDRPTR)); 4908c2ecf20Sopenharmony_ci writeb(value, net2272_reg_addr(dev, REGDATA)); 4918c2ecf20Sopenharmony_ci /* writeb(tmp, net2272_reg_addr(dev, REGADDRPTR)); */ 4928c2ecf20Sopenharmony_ci } else 4938c2ecf20Sopenharmony_ci writeb(value, net2272_reg_addr(dev, reg)); 4948c2ecf20Sopenharmony_ci} 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_cistatic u8 4978c2ecf20Sopenharmony_cinet2272_read(struct net2272 *dev, unsigned int reg) 4988c2ecf20Sopenharmony_ci{ 4998c2ecf20Sopenharmony_ci u8 ret; 5008c2ecf20Sopenharmony_ci 5018c2ecf20Sopenharmony_ci if (reg >= REG_INDEXED_THRESHOLD) { 5028c2ecf20Sopenharmony_ci /* 5038c2ecf20Sopenharmony_ci * Indexed register; use REGADDRPTR/REGDATA 5048c2ecf20Sopenharmony_ci * - Save and restore REGADDRPTR. This prevents REGADDRPTR from 5058c2ecf20Sopenharmony_ci * changes between other code sections, but it is time consuming. 5068c2ecf20Sopenharmony_ci * - Performance tips: either do not save and restore REGADDRPTR (if it 5078c2ecf20Sopenharmony_ci * is safe) or do save/restore operations only in critical sections. 5088c2ecf20Sopenharmony_ci u8 tmp = readb(dev->base_addr + REGADDRPTR); 5098c2ecf20Sopenharmony_ci */ 5108c2ecf20Sopenharmony_ci writeb((u8)reg, net2272_reg_addr(dev, REGADDRPTR)); 5118c2ecf20Sopenharmony_ci ret = readb(net2272_reg_addr(dev, REGDATA)); 5128c2ecf20Sopenharmony_ci /* writeb(tmp, net2272_reg_addr(dev, REGADDRPTR)); */ 5138c2ecf20Sopenharmony_ci } else 5148c2ecf20Sopenharmony_ci ret = readb(net2272_reg_addr(dev, reg)); 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci return ret; 5178c2ecf20Sopenharmony_ci} 5188c2ecf20Sopenharmony_ci 5198c2ecf20Sopenharmony_cistatic void 5208c2ecf20Sopenharmony_cinet2272_ep_write(struct net2272_ep *ep, unsigned int reg, u8 value) 5218c2ecf20Sopenharmony_ci{ 5228c2ecf20Sopenharmony_ci struct net2272 *dev = ep->dev; 5238c2ecf20Sopenharmony_ci 5248c2ecf20Sopenharmony_ci if (dev->pagesel != ep->num) { 5258c2ecf20Sopenharmony_ci net2272_write(dev, PAGESEL, ep->num); 5268c2ecf20Sopenharmony_ci dev->pagesel = ep->num; 5278c2ecf20Sopenharmony_ci } 5288c2ecf20Sopenharmony_ci net2272_write(dev, reg, value); 5298c2ecf20Sopenharmony_ci} 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_cistatic u8 5328c2ecf20Sopenharmony_cinet2272_ep_read(struct net2272_ep *ep, unsigned int reg) 5338c2ecf20Sopenharmony_ci{ 5348c2ecf20Sopenharmony_ci struct net2272 *dev = ep->dev; 5358c2ecf20Sopenharmony_ci 5368c2ecf20Sopenharmony_ci if (dev->pagesel != ep->num) { 5378c2ecf20Sopenharmony_ci net2272_write(dev, PAGESEL, ep->num); 5388c2ecf20Sopenharmony_ci dev->pagesel = ep->num; 5398c2ecf20Sopenharmony_ci } 5408c2ecf20Sopenharmony_ci return net2272_read(dev, reg); 5418c2ecf20Sopenharmony_ci} 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_cistatic void allow_status(struct net2272_ep *ep) 5448c2ecf20Sopenharmony_ci{ 5458c2ecf20Sopenharmony_ci /* ep0 only */ 5468c2ecf20Sopenharmony_ci net2272_ep_write(ep, EP_RSPCLR, 5478c2ecf20Sopenharmony_ci (1 << CONTROL_STATUS_PHASE_HANDSHAKE) | 5488c2ecf20Sopenharmony_ci (1 << ALT_NAK_OUT_PACKETS) | 5498c2ecf20Sopenharmony_ci (1 << NAK_OUT_PACKETS_MODE)); 5508c2ecf20Sopenharmony_ci ep->stopped = 1; 5518c2ecf20Sopenharmony_ci} 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_cistatic void set_halt(struct net2272_ep *ep) 5548c2ecf20Sopenharmony_ci{ 5558c2ecf20Sopenharmony_ci /* ep0 and bulk/intr endpoints */ 5568c2ecf20Sopenharmony_ci net2272_ep_write(ep, EP_RSPCLR, 1 << CONTROL_STATUS_PHASE_HANDSHAKE); 5578c2ecf20Sopenharmony_ci net2272_ep_write(ep, EP_RSPSET, 1 << ENDPOINT_HALT); 5588c2ecf20Sopenharmony_ci} 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_cistatic void clear_halt(struct net2272_ep *ep) 5618c2ecf20Sopenharmony_ci{ 5628c2ecf20Sopenharmony_ci /* ep0 and bulk/intr endpoints */ 5638c2ecf20Sopenharmony_ci net2272_ep_write(ep, EP_RSPCLR, 5648c2ecf20Sopenharmony_ci (1 << ENDPOINT_HALT) | (1 << ENDPOINT_TOGGLE)); 5658c2ecf20Sopenharmony_ci} 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_ci/* count (<= 4) bytes in the next fifo write will be valid */ 5688c2ecf20Sopenharmony_cistatic void set_fifo_bytecount(struct net2272_ep *ep, unsigned count) 5698c2ecf20Sopenharmony_ci{ 5708c2ecf20Sopenharmony_ci /* net2272_ep_write will truncate to u8 for us */ 5718c2ecf20Sopenharmony_ci net2272_ep_write(ep, EP_TRANSFER2, count >> 16); 5728c2ecf20Sopenharmony_ci net2272_ep_write(ep, EP_TRANSFER1, count >> 8); 5738c2ecf20Sopenharmony_ci net2272_ep_write(ep, EP_TRANSFER0, count); 5748c2ecf20Sopenharmony_ci} 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_cistruct net2272_request { 5778c2ecf20Sopenharmony_ci struct usb_request req; 5788c2ecf20Sopenharmony_ci struct list_head queue; 5798c2ecf20Sopenharmony_ci unsigned mapped:1, 5808c2ecf20Sopenharmony_ci valid:1; 5818c2ecf20Sopenharmony_ci}; 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_ci#endif 584