Changeset 34843


Ignore:
Timestamp:
2012-12-22T13:11:08+01:00 (5 years ago)
Author:
juhosg
Message:

ramips: convert to use {e,o}hci-platform driver

Signed-off-by: Gabor Juhos <juhosg@…>

Location:
trunk/target/linux/ramips
Files:
6 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/ramips/files/arch/mips/ralink/rt305x/devices.c

    r34270 r34843  
    1919#include <linux/delay.h> 
    2020#include <linux/dma-mapping.h> 
     21#include <linux/usb/ehci_pdriver.h> 
     22#include <linux/usb/ohci_pdriver.h> 
    2123 
    2224#include <asm/addrspace.h> 
     
    2830#include <ramips_eth_platform.h> 
    2931#include <rt305x_esw_platform.h> 
    30 #include <rt3883_ehci_platform.h> 
    31 #include <rt3883_ohci_platform.h> 
    3232 
    3333static struct resource rt305x_flash0_resources[] = { 
     
    298298}; 
    299299 
    300 static atomic_t rt3352_usb_use_count = ATOMIC_INIT(0); 
    301  
    302 static void rt3352_usb_host_start(void) 
    303 { 
    304         u32 t; 
    305  
    306         if (atomic_inc_return(&rt3352_usb_use_count) != 1) 
    307                 return; 
    308  
    309         t = rt305x_sysc_rr(RT3352_SYSC_REG_USB_PS); 
    310  
    311         /* enable clock for port0's and port1's phys */ 
    312         t = rt305x_sysc_rr(RT3352_SYSC_REG_CLKCFG1); 
    313         t = t | RT3352_CLKCFG1_UPHY0_CLK_EN | RT3352_CLKCFG1_UPHY1_CLK_EN; 
    314         rt305x_sysc_wr(t, RT3352_SYSC_REG_CLKCFG1); 
    315         mdelay(500); 
    316  
    317         /* pull USBHOST and USBDEV out from reset */ 
    318         t = rt305x_sysc_rr(RT3352_SYSC_REG_RSTCTRL); 
    319         t &= ~(RT3352_RSTCTRL_UHST | RT3352_RSTCTRL_UDEV); 
    320         rt305x_sysc_wr(t, RT3352_SYSC_REG_RSTCTRL); 
    321         mdelay(500); 
    322  
    323         /* enable host mode */ 
    324         t = rt305x_sysc_rr(RT3352_SYSC_REG_SYSCFG1); 
    325         t |= RT3352_SYSCFG1_USB0_HOST_MODE; 
    326         rt305x_sysc_wr(t, RT3352_SYSC_REG_SYSCFG1); 
    327  
    328         t = rt305x_sysc_rr(RT3352_SYSC_REG_USB_PS); 
    329 } 
    330  
    331 static void rt3352_usb_host_stop(void) 
    332 { 
    333         u32 t; 
    334  
    335         if (atomic_dec_return(&rt3352_usb_use_count) != 0) 
    336                 return; 
    337  
    338         /* put USBHOST and USBDEV into reset */ 
    339         t = rt305x_sysc_rr(RT3352_SYSC_REG_RSTCTRL); 
    340         t |= RT3352_RSTCTRL_UHST | RT3352_RSTCTRL_UDEV; 
    341         rt305x_sysc_wr(t, RT3352_SYSC_REG_RSTCTRL); 
    342         udelay(10000); 
    343  
    344         /* disable clock for port0's and port1's phys*/ 
    345         t = rt305x_sysc_rr(RT3352_SYSC_REG_CLKCFG1); 
    346         t &= ~(RT3352_CLKCFG1_UPHY0_CLK_EN | RT3352_CLKCFG1_UPHY1_CLK_EN); 
    347         rt305x_sysc_wr(t, RT3352_SYSC_REG_CLKCFG1); 
    348         udelay(10000); 
    349 } 
    350  
    351 static struct rt3883_ehci_platform_data rt3352_ehci_data = { 
    352         .start_hw       = rt3352_usb_host_start, 
    353         .stop_hw        = rt3352_usb_host_stop, 
     300static atomic_t rt3352_usb_pwr_ref = ATOMIC_INIT(0); 
     301 
     302static int rt3352_usb_power_on(struct platform_device *pdev) 
     303{ 
     304 
     305        if (atomic_inc_return(&rt3352_usb_pwr_ref) == 1) { 
     306                u32 t; 
     307 
     308                t = rt305x_sysc_rr(RT3352_SYSC_REG_USB_PS); 
     309 
     310                /* enable clock for port0's and port1's phys */ 
     311                t = rt305x_sysc_rr(RT3352_SYSC_REG_CLKCFG1); 
     312                t |= RT3352_CLKCFG1_UPHY0_CLK_EN | RT3352_CLKCFG1_UPHY1_CLK_EN; 
     313                rt305x_sysc_wr(t, RT3352_SYSC_REG_CLKCFG1); 
     314                mdelay(500); 
     315 
     316                /* pull USBHOST and USBDEV out from reset */ 
     317                t = rt305x_sysc_rr(RT3352_SYSC_REG_RSTCTRL); 
     318                t &= ~(RT3352_RSTCTRL_UHST | RT3352_RSTCTRL_UDEV); 
     319                rt305x_sysc_wr(t, RT3352_SYSC_REG_RSTCTRL); 
     320                mdelay(500); 
     321 
     322                /* enable host mode */ 
     323                t = rt305x_sysc_rr(RT3352_SYSC_REG_SYSCFG1); 
     324                t |= RT3352_SYSCFG1_USB0_HOST_MODE; 
     325                rt305x_sysc_wr(t, RT3352_SYSC_REG_SYSCFG1); 
     326 
     327                t = rt305x_sysc_rr(RT3352_SYSC_REG_USB_PS); 
     328        } 
     329 
     330        return 0; 
     331} 
     332 
     333static void rt3352_usb_power_off(struct platform_device *pdev) 
     334{ 
     335 
     336        if (atomic_dec_return(&rt3352_usb_pwr_ref) == 0) { 
     337                u32 t; 
     338 
     339                /* put USBHOST and USBDEV into reset */ 
     340                t = rt305x_sysc_rr(RT3352_SYSC_REG_RSTCTRL); 
     341                t |= RT3352_RSTCTRL_UHST | RT3352_RSTCTRL_UDEV; 
     342                rt305x_sysc_wr(t, RT3352_SYSC_REG_RSTCTRL); 
     343                udelay(10000); 
     344 
     345                /* disable clock for port0's and port1's phys*/ 
     346                t = rt305x_sysc_rr(RT3352_SYSC_REG_CLKCFG1); 
     347                t &= ~(RT3352_CLKCFG1_UPHY0_CLK_EN | RT3352_CLKCFG1_UPHY1_CLK_EN); 
     348                rt305x_sysc_wr(t, RT3352_SYSC_REG_CLKCFG1); 
     349                udelay(10000); 
     350        } 
     351} 
     352 
     353static struct usb_ehci_pdata rt3352_ehci_data = { 
     354        .port_power_off = 1, 
     355        .power_on       = rt3352_usb_power_on, 
     356        .power_off      = rt3352_usb_power_off, 
    354357}; 
    355358 
     
    368371static u64 rt3352_ehci_dmamask = DMA_BIT_MASK(32); 
    369372static struct platform_device rt3352_ehci_device = { 
    370         .name           = "rt3883-ehci", 
     373        .name           = "ehci-platform", 
    371374        .id             = -1, 
    372375        .resource       = rt3352_ehci_resources, 
     
    391394}; 
    392395 
    393 static struct rt3883_ohci_platform_data rt3352_ohci_data = { 
    394         .start_hw       = rt3352_usb_host_start, 
    395         .stop_hw        = rt3352_usb_host_stop, 
     396static struct usb_ohci_pdata rt3352_ohci_data = { 
     397        .power_on       = rt3352_usb_power_on, 
     398        .power_off      = rt3352_usb_power_off, 
    396399}; 
    397400 
    398401static u64 rt3352_ohci_dmamask = DMA_BIT_MASK(32); 
    399402static struct platform_device rt3352_ohci_device = { 
    400         .name           = "rt3883-ohci", 
     403        .name           = "ohci-platform", 
    401404        .id             = -1, 
    402405        .resource       = rt3352_ohci_resources, 
  • trunk/target/linux/ramips/files/arch/mips/ralink/rt3883/devices.c

    r31922 r34843  
    2020#include <linux/clk.h> 
    2121#include <linux/rt2x00_platform.h> 
     22#include <linux/usb/ehci_pdriver.h> 
     23#include <linux/usb/ohci_pdriver.h> 
    2224 
    2325#include <asm/addrspace.h> 
     
    2527#include <asm/mach-ralink/rt3883.h> 
    2628#include <asm/mach-ralink/rt3883_regs.h> 
    27 #include <asm/mach-ralink/rt3883_ehci_platform.h> 
    28 #include <asm/mach-ralink/rt3883_ohci_platform.h> 
    2929#include <asm/mach-ralink/ramips_nand_platform.h> 
    3030#include "devices.h" 
     
    124124} 
    125125 
    126 static atomic_t rt3883_usb_use_count = ATOMIC_INIT(0); 
    127  
    128 static void rt3883_usb_host_start(void) 
    129 { 
    130         u32 t; 
    131  
    132         if (atomic_inc_return(&rt3883_usb_use_count) != 1) 
    133                 return; 
    134  
    135         t = rt3883_sysc_rr(RT3883_SYSC_REG_USB_PS); 
    136  
    137 #if 0 
    138         /* put the HOST controller into reset */ 
    139         t = rt3883_sysc_rr(RT3883_SYSC_REG_RSTCTRL); 
    140         t |= RT3883_RSTCTRL_UHST; 
    141         rt3883_sysc_wr(t, RT3883_SYSC_REG_RSTCTRL); 
    142 #endif 
    143  
    144         /* enable clock for port0's and port1's phys */ 
    145         t = rt3883_sysc_rr(RT3883_SYSC_REG_CLKCFG1); 
    146         t = t | RT3883_CLKCFG1_UPHY0_CLK_EN | RT3883_CLKCFG1_UPHY1_CLK_EN; 
    147         rt3883_sysc_wr(t, RT3883_SYSC_REG_CLKCFG1); 
    148         mdelay(500); 
    149  
    150         /* pull USBHOST and USBDEV out from reset */ 
    151         t = rt3883_sysc_rr(RT3883_SYSC_REG_RSTCTRL); 
    152         t &= ~(RT3883_RSTCTRL_UHST | RT3883_RSTCTRL_UDEV); 
    153         rt3883_sysc_wr(t, RT3883_SYSC_REG_RSTCTRL); 
    154         mdelay(500); 
    155  
    156         /* enable host mode */ 
    157         t = rt3883_sysc_rr(RT3883_SYSC_REG_SYSCFG1); 
    158         t |= RT3883_SYSCFG1_USB0_HOST_MODE; 
    159         rt3883_sysc_wr(t, RT3883_SYSC_REG_SYSCFG1); 
    160  
    161         t = rt3883_sysc_rr(RT3883_SYSC_REG_USB_PS); 
    162 } 
    163  
    164 static void rt3883_usb_host_stop(void) 
    165 { 
    166         u32 t; 
    167  
    168         if (atomic_dec_return(&rt3883_usb_use_count) != 0) 
    169                 return; 
    170  
    171         /* put USBHOST and USBDEV into reset */ 
    172         t = rt3883_sysc_rr(RT3883_SYSC_REG_RSTCTRL); 
    173         t |= RT3883_RSTCTRL_UHST | RT3883_RSTCTRL_UDEV; 
    174         rt3883_sysc_wr(t, RT3883_SYSC_REG_RSTCTRL); 
    175         udelay(10000); 
    176  
    177         /* disable clock for port0's and port1's phys*/ 
    178         t = rt3883_sysc_rr(RT3883_SYSC_REG_CLKCFG1); 
    179         t &= ~(RT3883_CLKCFG1_UPHY0_CLK_EN | RT3883_CLKCFG1_UPHY1_CLK_EN); 
    180         rt3883_sysc_wr(t, RT3883_SYSC_REG_CLKCFG1); 
    181         udelay(10000); 
    182 } 
    183  
    184 static struct rt3883_ehci_platform_data rt3883_ehci_data = { 
    185         .start_hw       = rt3883_usb_host_start, 
    186         .stop_hw        = rt3883_usb_host_stop, 
     126static atomic_t rt3883_usb_pwr_ref = ATOMIC_INIT(0); 
     127 
     128static int rt3883_usb_power_on(struct platform_device *pdev) 
     129{ 
     130 
     131        if (atomic_inc_return(&rt3883_usb_pwr_ref) == 1) { 
     132                u32 t; 
     133 
     134                t = rt3883_sysc_rr(RT3883_SYSC_REG_USB_PS); 
     135 
     136                /* enable clock for port0's and port1's phys */ 
     137                t = rt3883_sysc_rr(RT3883_SYSC_REG_CLKCFG1); 
     138                t |= RT3883_CLKCFG1_UPHY0_CLK_EN | RT3883_CLKCFG1_UPHY1_CLK_EN; 
     139                rt3883_sysc_wr(t, RT3883_SYSC_REG_CLKCFG1); 
     140                mdelay(500); 
     141 
     142                /* pull USBHOST and USBDEV out from reset */ 
     143                t = rt3883_sysc_rr(RT3883_SYSC_REG_RSTCTRL); 
     144                t &= ~(RT3883_RSTCTRL_UHST | RT3883_RSTCTRL_UDEV); 
     145                rt3883_sysc_wr(t, RT3883_SYSC_REG_RSTCTRL); 
     146                mdelay(500); 
     147 
     148                /* enable host mode */ 
     149                t = rt3883_sysc_rr(RT3883_SYSC_REG_SYSCFG1); 
     150                t |= RT3883_SYSCFG1_USB0_HOST_MODE; 
     151                rt3883_sysc_wr(t, RT3883_SYSC_REG_SYSCFG1); 
     152 
     153                t = rt3883_sysc_rr(RT3883_SYSC_REG_USB_PS); 
     154        } 
     155 
     156        return 0; 
     157} 
     158 
     159static void rt3883_usb_power_off(struct platform_device *pdev) 
     160{ 
     161        if (atomic_dec_return(&rt3883_usb_pwr_ref) == 0) { 
     162                u32 t; 
     163 
     164                /* put USBHOST and USBDEV into reset */ 
     165                t = rt3883_sysc_rr(RT3883_SYSC_REG_RSTCTRL); 
     166                t |= RT3883_RSTCTRL_UHST | RT3883_RSTCTRL_UDEV; 
     167                rt3883_sysc_wr(t, RT3883_SYSC_REG_RSTCTRL); 
     168                udelay(10000); 
     169 
     170                /* disable clock for port0's and port1's phys*/ 
     171                t = rt3883_sysc_rr(RT3883_SYSC_REG_CLKCFG1); 
     172                t &= ~(RT3883_CLKCFG1_UPHY0_CLK_EN | 
     173                       RT3883_CLKCFG1_UPHY1_CLK_EN); 
     174                rt3883_sysc_wr(t, RT3883_SYSC_REG_CLKCFG1); 
     175                udelay(10000); 
     176        } 
     177} 
     178 
     179static struct usb_ehci_pdata rt3883_ehci_data = { 
     180        .port_power_off = 1, 
     181        .power_on       = rt3883_usb_power_on, 
     182        .power_off      = rt3883_usb_power_off, 
    187183}; 
    188184 
     
    201197static u64 rt3883_ehci_dmamask = DMA_BIT_MASK(32); 
    202198static struct platform_device rt3883_ehci_device = { 
    203         .name           = "rt3883-ehci", 
     199        .name           = "ehci-platform", 
    204200        .id             = -1, 
    205201        .resource       = rt3883_ehci_resources, 
     
    224220}; 
    225221 
    226 static struct rt3883_ohci_platform_data rt3883_ohci_data = { 
    227         .start_hw       = rt3883_usb_host_start, 
    228         .stop_hw        = rt3883_usb_host_stop, 
     222static struct usb_ohci_pdata rt3883_ohci_data = { 
     223        .power_on       = rt3883_usb_power_on, 
     224        .power_off      = rt3883_usb_power_off, 
    229225}; 
    230226 
    231227static u64 rt3883_ohci_dmamask = DMA_BIT_MASK(32); 
    232228static struct platform_device rt3883_ohci_device = { 
    233         .name           = "rt3883-ohci", 
     229        .name           = "ohci-platform", 
    234230        .id             = -1, 
    235231        .resource       = rt3883_ohci_resources, 
Note: See TracChangeset for help on using the changeset viewer.