From 284bbb120120e68173a4bd14f9209dfdbab49d19 Mon Sep 17 00:00:00 2001 From: hwg Date: Fri, 7 Mar 2014 09:12:45 +0800 Subject: [PATCH] support 3188 vmac --- arch/arm/boot/dts/rk3188-pinctrl.dtsi | 42 ++++ arch/arm/boot/dts/rk3188.dtsi | 8 + drivers/net/eth_mac/Kconfig | 51 ----- drivers/net/eth_mac/Makefile | 1 - drivers/net/eth_mac/eth_mac.c | 206 ------------------ drivers/net/eth_mac/eth_mac.h | 17 -- drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/rk/Kconfig | 16 ++ drivers/net/ethernet/rk/Makefile | 5 + drivers/net/ethernet/rk/vmac/Kconfig | 10 + drivers/net/ethernet/rk/vmac/Makefile | 2 + .../net/{ => ethernet/rk/vmac}/rk29_vmac.c | 150 ++++++------- .../net/{ => ethernet/rk/vmac}/rk29_vmac.h | 13 +- drivers/net/ethernet/rk/vmac/rk29_vmac_phy.c | 109 +++++++++ drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c | 8 +- 16 files changed, 287 insertions(+), 353 deletions(-) delete mode 100755 drivers/net/eth_mac/Kconfig delete mode 100755 drivers/net/eth_mac/Makefile delete mode 100755 drivers/net/eth_mac/eth_mac.c delete mode 100755 drivers/net/eth_mac/eth_mac.h mode change 100644 => 100755 drivers/net/ethernet/Kconfig mode change 100644 => 100755 drivers/net/ethernet/Makefile create mode 100755 drivers/net/ethernet/rk/Kconfig create mode 100755 drivers/net/ethernet/rk/Makefile create mode 100755 drivers/net/ethernet/rk/vmac/Kconfig create mode 100755 drivers/net/ethernet/rk/vmac/Makefile rename drivers/net/{ => ethernet/rk/vmac}/rk29_vmac.c (89%) rename drivers/net/{ => ethernet/rk/vmac}/rk29_vmac.h (92%) create mode 100755 drivers/net/ethernet/rk/vmac/rk29_vmac_phy.c diff --git a/arch/arm/boot/dts/rk3188-pinctrl.dtsi b/arch/arm/boot/dts/rk3188-pinctrl.dtsi index bb46bc6f4231..694549ca73d7 100755 --- a/arch/arm/boot/dts/rk3188-pinctrl.dtsi +++ b/arch/arm/boot/dts/rk3188-pinctrl.dtsi @@ -692,6 +692,48 @@ }; }; + gpio3_rmii { + rmii_clkoutpin: rmii-clkoutpin { + rockchip,pins = ; + rockchip,pull = ; + //rockchip,voltage = ; + rockchip,drive = ; + //rockchip,tristate = ; + }; + + rmii_clkinpin: rmii-clkinpin { + rockchip,pins = ; + rockchip,pull = ; + //rockchip,voltage = ; + rockchip,drive = ; + //rockchip,tristate = ; + }; + + rmii_txpins: rmii-txpins { + rockchip,pins = , , ; + rockchip,pull = ; + //rockchip,voltage = ; + rockchip,drive = ; + //rockchip,tristate = ; + }; + + rmii_rxpins: rmii-rxpins { + rockchip,pins = , , , ; + rockchip,pull = ; + //rockchip,voltage = ; + rockchip,drive = ; + //rockchip,tristate = ; + }; + + rmii_mdpins: rmii-mdpins { + rockchip,pins = , ; + rockchip,pull = ; + //rockchip,voltage = ; + rockchip,drive = ; + //rockchip,tristate = ; + }; + }; + gps { gps_mag:gps-mag { rockchip,pins = ; diff --git a/arch/arm/boot/dts/rk3188.dtsi b/arch/arm/boot/dts/rk3188.dtsi index 79da82eb7621..b4834797b70b 100755 --- a/arch/arm/boot/dts/rk3188.dtsi +++ b/arch/arm/boot/dts/rk3188.dtsi @@ -626,4 +626,12 @@ "hsicphy12m", "hsic_otgphy1"; }; + vmac@0x10204000 { + compatible = "rockchip,vmac"; + reg = <0x10204000 0x4000>; + interrupts = ; + pinctrl-names = "default", "gpio"; + pinctrl-0 = <&rmii_clkoutpin &rmii_txpins &rmii_rxpins &rmii_mdpins>; + pinctrl-1 = <&rmii_clkinpin &rmii_txpins &rmii_rxpins &rmii_mdpins>; + }; }; diff --git a/drivers/net/eth_mac/Kconfig b/drivers/net/eth_mac/Kconfig deleted file mode 100755 index 933563ae521b..000000000000 --- a/drivers/net/eth_mac/Kconfig +++ /dev/null @@ -1,51 +0,0 @@ -# -# set Ethernet mac source -# -choice - prompt "Ethernet mac source" - depends on NETDEV_10000 ||NETDEV_1000 ||NET_ETHERNET - default ETH_MAC_FROM_RANDOM - - config ETH_MAC_FROM_RANDOM - bool "Random Ethernet mac " - ---help--- - Say Y here if you want to set Random mac to Ethernet mac. - - This option alone does not add any kernel code. - - If you say N, all options in this submenu will be skipped and disabled. - - config ETH_MAC_FROM_EEPROM - bool "Ethernet mac from EEPROM" - depends on EEPROM_AT24C16 - ---help--- - Say Y here if you want to set EEPROM mac to Ethernet mac, - when the EEPROM exsits and mac has been written in. - - This option alone does not add any kernel code. - - If you say N, all options in this submenu will be skipped and disabled. - - config ETH_MAC_FROM_IDB - bool "Ethernet mac from IDB" - ---help--- - Say Y here if you want to set IDB mac to Ethernet mac, - when the IDB mac has been written in. - - This option alone does not add any kernel code. - - If you say N, all options in this submenu will be skipped and disabled. - -endchoice - -config PHY_PORT_NUM - int "phy port number selected (More than one port on Switch)" - depends on RK29_VMAC - default 0 - help - 0:phy dev 0:00 - 1:phy dev 0:01 - 2:phy dev 0:02 - ---More--- - - diff --git a/drivers/net/eth_mac/Makefile b/drivers/net/eth_mac/Makefile deleted file mode 100755 index c745b3d64a34..000000000000 --- a/drivers/net/eth_mac/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-y += eth_mac.o diff --git a/drivers/net/eth_mac/eth_mac.c b/drivers/net/eth_mac/eth_mac.c deleted file mode 100755 index 96f5de4bba72..000000000000 --- a/drivers/net/eth_mac/eth_mac.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (C) 2010 ROCKCHIP, Inc. - * Author: roger_chen - * - * This program is the virtual flash device - * used to store bd_addr or MAC - * - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "eth_mac.h" - -#if 1 -#define DBG(x...) printk("eth_mac:" x) -#else -#define DBG(x...) -#endif - -#define VERSION "0.1" - -#define WLAN_MAC_FILE "/data/misc/wifi/wlan_mac" - -//extern char GetSNSectorInfo(char * pbuf); - -static char GetSNSectorInfoBeforeNandInit(char * pbuf) -{ - char * sn_addr = ioremap(0x10501600,0x200); - memcpy(pbuf,sn_addr,0x200); - iounmap(sn_addr); - //print_hex_dump(KERN_WARNING, "sn:", DUMP_PREFIX_NONE, 16,1, sn_addr, 16, 0); - return 0; -} - -int eth_mac_read_from_IDB(u8 *mac) -{ - int i; - char *tempBuf = kmalloc(512, GFP_KERNEL); - - if(mac == NULL) - return -EFAULT; - - GetSNSectorInfoBeforeNandInit(tempBuf); - /*for (i = 0; i < 512; i++) { - printk("%02x, ", tempBuf[i]); - if(((i+1)%16) == 0) printk("\n"); - }*/ - - for (i = 506; i <= 511; i++) - mac[i-506] = tempBuf[i]; - - kfree(tempBuf); - - return 0; -} - -int eth_mac_idb(u8 *eth_mac) -{ - int i; - int err = 0; - memset(eth_mac, 0, 6); - err = eth_mac_read_from_IDB(eth_mac); - if (err) - return -1; - printk("Read the Ethernet MAC address from IDB:"); - for (i = 0; i < 5; i++) - printk("%2.2x:", eth_mac[i]); - printk("%2.2x\n", eth_mac[i]); - - return 0; -} - -/** -*大写转小写 -* -*/ -static void to_lower(char *str) -{ - int i=0; - while(str[i]!=0) - { - if((str[i] >= 'A')&&(str[i] <= 'Z')) - str[i]+=32; - i++; - } -} - - -/** - *字符串格式转为mac 格式. - * - * - */ -static void trans( char *src ,int * k) -{ - char c; - int i; - int temp; - int temp2; - - if( (src == NULL) ||(strlen(src) <16 ) ) // 参数检查 - { - printk( "Arg Error\n" ); - return ; - } - - for( i = 0; i < 6; i++ ) - { - temp = 0; - temp2 = 0; - c = *src; - if( c == ':' ){ - src++; - c = *src; - } - if( c >= 'a' && c <= 'f' ) // 两个字符中的第一个 比如 "0f" ,则表示是字符 '0' - temp = ( c - 'a' ) + 10; - else - temp = ( c - '0' ) ; - src++; - - c = *src; - if( i == 5){ //wifi mac 末尾加1 - if(c =='f'){ - c = '0'; - } if (c == '9'){ - c = 'a'; - }else{ - c = c + 1; - } - } - if( c >= 'a' && c <= 'f' ) // 两个字符中的第二个,如 "f8" ,那么表示字符 '8' - temp2 = ( c - 'a' ) + 10; - else - temp2 = ( c - '0' ) ; - - temp = temp * 16; - temp += temp2; - src++; - *(k+i) = temp; - - } - -} - -/*int eth_mac_wifi(u8 *eth_mac){ - int i; - struct file *file = NULL; - char wifi_mac[32]; - mm_segment_t old_fs; - ssize_t ret; - int maci[6]; - - memset(eth_mac, 0, 6); - - file = filp_open(WLAN_MAC_FILE, O_RDWR,0); - if (IS_ERR(file)) - { - printk("open %s failed.", WLAN_MAC_FILE); - return -ENOENT; - } - - old_fs = get_fs(); - set_fs(get_ds()); - - file->f_op->llseek(file,0,0); - ret = file->f_op->read(file, wifi_mac, 32, &file->f_pos); - - set_fs(old_fs); - - if(ret > 0){ - //printk("mac read from %s: %s\n", WLAN_MAC_FILE,wifi_mac); - - to_lower(wifi_mac); - trans(wifi_mac,maci); - for (i = 0;i< 6;i++){ - eth_mac[i] = maci[i]; - } - - } - else if(ret == 0) - printk("read nothing from %s........\n",WLAN_MAC_FILE); - else - { - printk("read wifi mac error\n"); - return -ENOENT; - } - - filp_close(file,NULL); - return 0; - -}*/ - - - - - diff --git a/drivers/net/eth_mac/eth_mac.h b/drivers/net/eth_mac/eth_mac.h deleted file mode 100755 index 03db62788352..000000000000 --- a/drivers/net/eth_mac/eth_mac.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _ETH_MAC_H_ -#define _ETH_MAC_H_ -/* - * eth_mac/eth_mac.h - * - * Copyright (C) 2001 Russell King. - * - * This file is placed under the LGPL. - * - * - * - */ -//int eth_mac_read_from_IDB(u8 *mac) - -int eth_mac_idb(u8 *eth_mac); -int eth_mac_wifi(u8 *eth_mac); -#endif /* _ETH_MAC_H_ */ diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig old mode 100644 new mode 100755 index ed956e08d38b..f651b27c9696 --- a/drivers/net/ethernet/Kconfig +++ b/drivers/net/ethernet/Kconfig @@ -167,5 +167,6 @@ source "drivers/net/ethernet/via/Kconfig" source "drivers/net/ethernet/wiznet/Kconfig" source "drivers/net/ethernet/xilinx/Kconfig" source "drivers/net/ethernet/xircom/Kconfig" +source "drivers/net/ethernet/rk/Kconfig" endif # ETHERNET diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile old mode 100644 new mode 100755 index 8268d85f9448..b3925e9cbabc --- a/drivers/net/ethernet/Makefile +++ b/drivers/net/ethernet/Makefile @@ -74,3 +74,4 @@ obj-$(CONFIG_NET_VENDOR_VIA) += via/ obj-$(CONFIG_NET_VENDOR_WIZNET) += wiznet/ obj-$(CONFIG_NET_VENDOR_XILINX) += xilinx/ obj-$(CONFIG_NET_VENDOR_XIRCOM) += xircom/ +obj-$(CONFIG_NET_VENDOR_ROCKCHIP) += rk/ diff --git a/drivers/net/ethernet/rk/Kconfig b/drivers/net/ethernet/rk/Kconfig new file mode 100755 index 000000000000..be5f534e70d6 --- /dev/null +++ b/drivers/net/ethernet/rk/Kconfig @@ -0,0 +1,16 @@ +# +# rockchip device configuration +# + +config NET_VENDOR_ROCKCHIP + bool "Rockchip devices" + default y + depends on HAS_IOMEM + ---help--- + Rockchip devices + +if NET_VENDOR_ROCKCHIP + +source "drivers/net/ethernet/rk/vmac/Kconfig" + +endif # NET_VENDOR_ROCKCHIP diff --git a/drivers/net/ethernet/rk/Makefile b/drivers/net/ethernet/rk/Makefile new file mode 100755 index 000000000000..e36c612ba7cb --- /dev/null +++ b/drivers/net/ethernet/rk/Makefile @@ -0,0 +1,5 @@ +# +# Makefile for the rockchip device drivers. +# + +obj-$(CONFIG_RK_VMAC_ETH) += vmac/ diff --git a/drivers/net/ethernet/rk/vmac/Kconfig b/drivers/net/ethernet/rk/vmac/Kconfig new file mode 100755 index 000000000000..23f5af837e7f --- /dev/null +++ b/drivers/net/ethernet/rk/vmac/Kconfig @@ -0,0 +1,10 @@ +config RK_VMAC_ETH + bool "Rockchip 10/100 Ethernet driver" + depends on HAS_IOMEM && HAS_DMA + select NET_CORE + select MII + select PHYLIB + select CRC32 + ---help--- + Rockchip 10/100 VMAC Ethernet driver. + diff --git a/drivers/net/ethernet/rk/vmac/Makefile b/drivers/net/ethernet/rk/vmac/Makefile new file mode 100755 index 000000000000..4de386217110 --- /dev/null +++ b/drivers/net/ethernet/rk/vmac/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_RK_VMAC_ETH) += rk29_vmac.o +obj-$(CONFIG_RK_VMAC_ETH) += rk29_vmac_phy.o diff --git a/drivers/net/rk29_vmac.c b/drivers/net/ethernet/rk/vmac/rk29_vmac.c similarity index 89% rename from drivers/net/rk29_vmac.c rename to drivers/net/ethernet/rk/vmac/rk29_vmac.c index 8a134a5a31c7..16e69c4e2510 100755 --- a/drivers/net/rk29_vmac.c +++ b/drivers/net/ethernet/rk/vmac/rk29_vmac.c @@ -27,7 +27,7 @@ * Authors: amit.bhor@celunite.com, sameer.dhavale@celunite.com */ -//#define DEBUG +#define DEBUG #include #include @@ -46,16 +46,16 @@ #include #include #include - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "rk29_vmac.h" -#include "eth_mac/eth_mac.h" -static struct wake_lock idlelock; /* add by lyx @ 20110302 */ +//static struct wake_lock idlelock; /* add by lyx @ 20110302 */ /* Register access macros */ #define vmac_writel(port, value, reg) \ @@ -176,7 +176,7 @@ static void vmac_handle_link_change(struct net_device *dev) phy_print_status(ap->phy_dev); } -static int __devinit vmac_mii_probe(struct net_device *dev) +static int vmac_mii_probe(struct net_device *dev) { struct vmac_priv *ap = netdev_priv(dev); struct phy_device *phydev = NULL; @@ -205,9 +205,8 @@ static int __devinit vmac_mii_probe(struct net_device *dev) /* add pin_irq, if avail */ phydev = phy_connect(dev, dev_name(&phydev->dev), - &vmac_handle_link_change, 0, - //PHY_INTERFACE_MODE_MII); - PHY_INTERFACE_MODE_RMII);//???????? + &vmac_handle_link_change, + PHY_INTERFACE_MODE_RMII); if (IS_ERR(phydev)) { err = PTR_ERR(phydev); dev_err(&dev->dev, "could not attach to PHY %d\n", err); @@ -217,27 +216,6 @@ static int __devinit vmac_mii_probe(struct net_device *dev) phydev->supported &= PHY_BASIC_FEATURES; phydev->supported |= SUPPORTED_Asym_Pause | SUPPORTED_Pause; -#if 0 - sys_clk = clk_get(NULL, "mac_ref");//////// - if (IS_ERR(sys_clk)) { - err = PTR_ERR(sys_clk); - goto err_disconnect; - } - - clk_set_rate(sys_clk,50000000); - clock_rate = clk_get_rate(sys_clk); - clk_put(sys_clk); - - printk("%s::%d --mac clock = %d\n",__func__, __LINE__, clock_rate); - dev_dbg(&ap->pdev->dev, "clk_get: dev_name : %s %lu\n", - dev_name(&ap->pdev->dev), - clock_rate); - - if (clock_rate < 25000000) - phydev->supported &= ~(SUPPORTED_100baseT_Half | - SUPPORTED_100baseT_Full); -#endif - phydev->advertising = phydev->supported; ap->link = 0; @@ -252,7 +230,7 @@ err_out: return err; } -static int __devinit vmac_mii_init(struct vmac_priv *ap) +static int vmac_mii_init(struct vmac_priv *ap) { int err, i; @@ -1045,6 +1023,7 @@ int vmac_open(struct net_device *dev) struct rk29_vmac_platform_data *pdata = ap->pdev->dev.platform_data; unsigned char current_mac[6]; int ret = 0; + struct pinctrl_state *clkout_state; printk("enter func %s...\n", __func__); @@ -1054,10 +1033,21 @@ int vmac_open(struct net_device *dev) wake_lock_timeout(&ap->resume_lock, 5*HZ); ap->shutdown = 0; + + // switch to rmii + printk("ap->pdev->dev.pins->p = %p\n", ap->pdev->dev.pins->p); + clkout_state = pinctrl_lookup_state(ap->pdev->dev.pins->p, "default"); + if (IS_ERR(clkout_state)) { + dev_err(&ap->pdev->dev, "no clkout pinctrl state\n"); + goto err_out; + } + + printk("in pinctrl_select_state.\n"); + pinctrl_select_state(ap->pdev->dev.pins->p, clkout_state); //set rmii ref clock 50MHz - mac_clk = clk_get(NULL, "mac_ref"); - if (IS_ERR(mac_clk)) + mac_clk = devm_clk_get(&ap->pdev->dev, "clk_mac"); + /*if (IS_ERR(mac_clk)) mac_clk = NULL; arm_clk = clk_get(NULL, "arm_pll"); if (IS_ERR(arm_clk)) @@ -1078,14 +1068,13 @@ int vmac_open(struct net_device *dev) pr_err("mac_clkin get fail\n"); } clk_set_parent(mac_clk, mac_clkin); - } + }*/ clk_set_rate(mac_clk, 50000000); - clk_enable(mac_clk); - clk_enable(clk_get(NULL,"mii_rx")); - clk_enable(clk_get(NULL,"mii_tx")); - clk_enable(clk_get(NULL,"hclk_mac")); - clk_enable(clk_get(NULL,"mac_ref")); + clk_prepare_enable(mac_clk); + //clk_enable(clk_get(NULL,"mii_rx")); + //clk_enable(clk_get(NULL,"mii_tx")); + //clk_enable(clk_get(NULL,"hclk_mac")); //phy power on if (pdata && pdata->rmii_power_control) @@ -1216,8 +1205,8 @@ err_free_irq: err_free_buffers: free_buffers(dev); err_out: - if (arm_clk && mac_parent && (arm_clk == mac_parent)) - wake_unlock(&idlelock); + //if (arm_clk && mac_parent && (arm_clk == mac_parent)) + // wake_unlock(&idlelock); return err; } @@ -1271,7 +1260,7 @@ int vmac_close(struct net_device *dev) pdata->rmii_power_control(0); //clock close - mac_clk = clk_get(NULL, "mac_ref_div"); + /*mac_clk = clk_get(NULL, "mac_ref_div"); if (IS_ERR(mac_clk)) mac_clk = NULL; if (mac_clk) { @@ -1284,13 +1273,12 @@ int vmac_close(struct net_device *dev) arm_clk = NULL; if (arm_clk && mac_parent && (arm_clk == mac_parent)) - wake_unlock(&idlelock); + wake_unlock(&idlelock);*/ - clk_disable(mac_clk); - clk_disable(clk_get(NULL,"mii_rx")); - clk_disable(clk_get(NULL,"mii_tx")); - clk_disable(clk_get(NULL,"hclk_mac")); - clk_disable(clk_get(NULL,"mac_ref")); + clk_disable(clk_get(&ap->pdev->dev,"clk_mac")); + //clk_disable(clk_get(NULL,"mii_tx")); + //clk_disable(clk_get(NULL,"hclk_mac")); + //clk_disable(clk_get(NULL,"clk_mac_pll")); return 0; } @@ -1547,19 +1535,26 @@ static const struct net_device_ops vmac_netdev_ops = { .ndo_do_ioctl = vmac_ioctl, .ndo_set_mac_address = eth_mac_addr, .ndo_tx_timeout = vmac_tx_timeout, - .ndo_set_multicast_list = vmac_set_multicast_list, + //.ndo_set_multicast_list = vmac_set_multicast_list, .ndo_validate_addr = eth_validate_addr, .ndo_change_mtu = eth_change_mtu, }; -static int __devinit vmac_probe(struct platform_device *pdev) +static int vmac_probe(struct platform_device *pdev) { struct net_device *dev; struct vmac_priv *ap; struct resource *res; unsigned int mem_base, mem_size, irq; int err; - struct rk29_vmac_platform_data *pdata = pdev->dev.platform_data; + struct rk29_vmac_platform_data *pdata; + struct device_node *np = pdev->dev.of_node; + + printk("vmac_probe.\n"); + dev_dbg(&pdev->dev, "vmac_probe 1.\n"); + + pdev->dev.platform_data = &board_vmac_data; + pdata = pdev->dev.platform_data; dev = alloc_etherdev(sizeof(*ap)); if (!dev) { @@ -1579,18 +1574,21 @@ static int __devinit vmac_probe(struct platform_device *pdev) mem_size = resource_size(res); irq = platform_get_irq(pdev, 0); - err = -EBUSY; - if (!request_mem_region(mem_base, mem_size, VMAC_NAME)) { + /*err = -EBUSY; + if (!devm_request_mem_region(&pdev->dev, mem_base, mem_size, VMAC_NAME)) { dev_err(&pdev->dev, "no memory region available\n"); goto err_out; - } + }*/ err = -ENOMEM; - ap->regs = ioremap(mem_base, mem_size); + ap->regs = devm_ioremap_resource(&pdev->dev, res); if (!ap->regs) { dev_err(&pdev->dev, "failed to map registers, aborting.\n"); goto err_out_release_mem; } + + printk("mem_base = 0x%08x, mem_size = 0x%08x, irq = %d, regs = 0x%08x\n", + mem_base, mem_size, irq, ap->regs); /* no checksum support, hence no scatter/gather */ dev->features |= NETIF_F_HIGHDMA; @@ -1639,7 +1637,7 @@ static int __devinit vmac_probe(struct platform_device *pdev) ap->suspending = 0; ap->open_flag = 0; - wake_lock_init(&idlelock, WAKE_LOCK_IDLE, "vmac"); + //wake_lock_init(&idlelock, WAKE_LOCK_IDLE, "vmac"); wake_lock_init(&ap->resume_lock, WAKE_LOCK_SUSPEND, "vmac_resume"); //config rk29 vmac as rmii, 100MHz @@ -1661,14 +1659,14 @@ err_out: return err; } -static int __devexit vmac_remove(struct platform_device *pdev) +static int vmac_remove(struct platform_device *pdev) { struct net_device *dev; struct vmac_priv *ap; struct resource *res; struct rk29_vmac_platform_data *pdata = pdev->dev.platform_data; - wake_lock_destroy(&idlelock); + //wake_lock_destroy(&idlelock); //power gpio deinit, phy power off if (pdata && pdata->rmii_io_deinit) @@ -1706,11 +1704,10 @@ static void rk29_vmac_power_off(struct net_device *dev) pdata->rmii_power_control(0); //clock close - clk_disable(clk_get(NULL, "mac_ref_div")); - clk_disable(clk_get(NULL,"mii_rx")); - clk_disable(clk_get(NULL,"mii_tx")); - clk_disable(clk_get(NULL,"hclk_mac")); - clk_disable(clk_get(NULL,"mac_ref")); + clk_disable(clk_get(&ap->pdev->dev,"clk_mac")); + //clk_disable(clk_get(NULL,"mii_tx")); + //clk_disable(clk_get(NULL,"hclk_mac")); + //clk_disable(clk_get(NULL,"clk_mac_pll")); } @@ -1765,25 +1762,32 @@ static struct dev_pm_ops rk29_vmac_pm_ops = { .resume = rk29_vmac_resume, }; +static const struct of_device_id rockchip_vmac_of_match[] = { + { .compatible = "rockchip,vmac", .data = NULL, }, + {}, +}; +MODULE_DEVICE_TABLE(of, rockchip_vmac_of_match); -static struct platform_driver rk29_vmac_driver = { +static struct platform_driver rockchip_vmac_driver = { .probe = vmac_probe, - .remove = __devexit_p(vmac_remove), + .remove = vmac_remove, .driver = { - .name = "rk29 vmac", - .owner = THIS_MODULE, - .pm = &rk29_vmac_pm_ops, + .owner = THIS_MODULE, + .name = "rockchip,vmac", + .pm = &rk29_vmac_pm_ops, + .of_match_table = of_match_ptr(rockchip_vmac_of_match), }, }; static int __init vmac_init(void) { - return platform_driver_register(&rk29_vmac_driver); + printk("vmac_init.\n"); + return platform_driver_register(&rockchip_vmac_driver); } static void __exit vmac_exit(void) { - platform_driver_unregister(&rk29_vmac_driver); + platform_driver_unregister(&rockchip_vmac_driver); } module_init(vmac_init); diff --git a/drivers/net/rk29_vmac.h b/drivers/net/ethernet/rk/vmac/rk29_vmac.h similarity index 92% rename from drivers/net/rk29_vmac.h rename to drivers/net/ethernet/rk/vmac/rk29_vmac.h index 25692a0dee8b..a6cf94e28ea0 100755 --- a/drivers/net/rk29_vmac.h +++ b/drivers/net/ethernet/rk/vmac/rk29_vmac.h @@ -27,7 +27,7 @@ #ifndef _ARCVMAC_H #define _ARCVMAC_H -#define VMAC_NAME "rk29 vmac" +#define VMAC_NAME "rockchip,vmac" #define VMAC_VERSION "1.0" /* Buffer descriptors */ @@ -273,4 +273,15 @@ static inline int fifo_inc_ct(int ct, int size) return (++ct == size) ? 0 : ct; } +/*vmac*/ +struct rk29_vmac_platform_data { + int (*vmac_register_set)(void); + int (*rmii_io_init)(void); + int (*rmii_io_deinit)(void); + int (*rmii_power_control)(int enable); + int(*rmii_speed_switch)(int speed); +}; + +extern struct rk29_vmac_platform_data board_vmac_data; + #endif /* _ARCVMAC_H */ diff --git a/drivers/net/ethernet/rk/vmac/rk29_vmac_phy.c b/drivers/net/ethernet/rk/vmac/rk29_vmac_phy.c new file mode 100755 index 000000000000..2adb9f9bc8ba --- /dev/null +++ b/drivers/net/ethernet/rk/vmac/rk29_vmac_phy.c @@ -0,0 +1,109 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../../../../arch/arm/mach-rockchip/iomap.h" +#include "../../../../../arch/arm/mach-rockchip/grf.h" + +#include "rk29_vmac.h" + +#define grf_readl(offset) readl_relaxed(RK_GRF_VIRT + offset) +#define grf_writel(v, offset) do { writel_relaxed(v, RK_GRF_VIRT + offset); dsb(); } while (0) + +static int rk30_vmac_register_set(void) +{ + //config rk30 vmac as rmii + writel_relaxed(0x3 << 16 | 0x2, RK_GRF_VIRT + RK3188_GRF_SOC_CON1); + return 0; +} + +static int rk30_rmii_io_init(void) +{ + int err; + long val; + printk("enter %s ",__func__); + + //rk3188 gpio3 and sdio drive strength , + val = grf_readl(RK3188_GRF_IO_CON3); + grf_writel(val|(0x0f<<16)|0x0f, RK3188_GRF_IO_CON3); + + //phy power gpio + /*err = gpio_request(PHY_PWR_EN_GPIO, "phy_power_en"); + if (err) { + printk("request phy power en pin faile ! \n"); + return -1; + } + //phy power down + gpio_direction_output(PHY_PWR_EN_GPIO, !PHY_PWR_EN_VALUE); + gpio_set_value(PHY_PWR_EN_GPIO, !PHY_PWR_EN_VALUE);*/ + + return 0; +} + +static int rk30_rmii_io_deinit(void) +{ + //phy power down + printk("enter %s ",__func__); + //gpio_direction_output(PHY_PWR_EN_GPIO, !PHY_PWR_EN_VALUE); + //gpio_set_value(PHY_PWR_EN_GPIO, !PHY_PWR_EN_VALUE); + //free + //gpio_free(PHY_PWR_EN_GPIO); + return 0; +} + +static int rk30_rmii_power_control(int enable) +{ + printk("enter %s ,enable = %d ",__func__,enable); + if (enable) { + //enable phy power + printk("power on phy\n"); + + //gpio_direction_output(PHY_PWR_EN_GPIO, PHY_PWR_EN_VALUE); + //gpio_set_value(PHY_PWR_EN_GPIO, PHY_PWR_EN_VALUE); + + //gpio reset + }else { + //gpio_direction_output(PHY_PWR_EN_GPIO, !PHY_PWR_EN_VALUE); + //gpio_set_value(PHY_PWR_EN_GPIO, !PHY_PWR_EN_VALUE); + } + return 0; +} + +#define BIT_EMAC_SPEED_100M (1 << 1) +#define BIT_EMAC_SPEED_10M (0 << 1) +static int rk29_vmac_speed_switch(int speed) +{ + //printk("%s--speed=%d\n", __FUNCTION__, speed); + if (10 == speed) { + writel_relaxed((2<<16)|BIT_EMAC_SPEED_10M, RK_GRF_VIRT + RK3188_GRF_SOC_CON1); + } else { + writel_relaxed((2<<16)|BIT_EMAC_SPEED_100M, RK_GRF_VIRT + RK3188_GRF_SOC_CON1); + } +} + +struct rk29_vmac_platform_data board_vmac_data = { + .vmac_register_set = rk30_vmac_register_set, + .rmii_io_init = rk30_rmii_io_init, + .rmii_io_deinit = rk30_rmii_io_deinit, + .rmii_power_control = rk30_rmii_power_control, + .rmii_speed_switch = rk29_vmac_speed_switch, +}; diff --git a/drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c b/drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c index ab8abc4b54f0..7ec0781ec6a5 100755 --- a/drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c +++ b/drivers/usb/dwc_otg_310/dwc_otg_hcd_linux.c @@ -485,8 +485,8 @@ int otg20_hcd_init( struct platform_device *_dev ) #endif #if 0//LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) /* Do not to do HNP polling if not capable */ - if (otg_dev->core_if->otg_ver) - hcd->self.is_hnp_cap = dwc_otg_get_hnpcapable(otg_dev->core_if); + //if (otg_dev->core_if->otg_ver) + // hcd->self.is_hnp_cap = dwc_otg_get_hnpcapable(otg_dev->core_if); #endif /* * Finish generic HCD initialization and start the HCD. This function @@ -580,8 +580,8 @@ int host20_hcd_init( struct platform_device *_dev ) #endif #if 0//LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) /* Do not to do HNP polling if not capable */ - if (otg_dev->core_if->otg_ver) - hcd->self.is_hnp_cap = dwc_otg_get_hnpcapable(otg_dev->core_if); + //if (otg_dev->core_if->otg_ver) + // hcd->self.is_hnp_cap = dwc_otg_get_hnpcapable(otg_dev->core_if); #endif /* * Finish generic HCD initialization and start the HCD. This function -- 2.34.1