V_01-00-18

1. Added support for GPIO configuration API
This commit is contained in:
TC956X 2021-10-21 16:04:11 +09:00 committed by jianzhou
parent ec5b1e771c
commit 8d374ba749
5 changed files with 164 additions and 5 deletions

View File

@ -1,7 +1,7 @@
# Toshiba Electronic Devices & Storage Corporation TC956X PCIe Ethernet Host Driver
Release Date: 19 Oct 2021
Release Date: 21 Oct 2021
Release Version: V_01-00-17 : Limited-tested version
Release Version: V_01-00-18 : Limited-tested version
TC956X PCIe EMAC driver is based on "Fedora 30, kernel-5.4.19".
@ -254,3 +254,7 @@ Default Configuraton:
1. Added M3 SRAM Debug counters to ethtool statistics.
2. Added MTL RX Overflow/packet miss count, TX underflow counts,Rx Watchdog value to ethtool statistics.
## TC956X_Host_Driver_20211021_V_01-00-18:
1. Added support for GPIO configuration API

View File

@ -51,6 +51,8 @@
* 19 Oct 2021 : 1. Adding M3 SRAM Debug counters to ethtool statistics
* 2. Adding MTL RX Overflow/packet miss count, TX underflow counts,Rx Watchdog value to ethtool statistics.
* VERSION : 01-00-17
* 21 Oct 2021 : 1. Added support for GPIO configuration API
* VERSION : 01-00-18
*/
#ifndef __COMMON_H__
@ -723,10 +725,44 @@ enum packets_types {
#define NFUNCEN6_OFFSET (0x1530)
#define NFUNCEN7_OFFSET (0x153C)
#define NFUNCEN_FUNC0 (0)
#define NFUNCEN4_GPIO_00 GENMASK(3, 0)
#define NFUNCEN4_GPIO_00_SHIFT (0)
#define NFUNCEN4_GPIO_01 GENMASK(7, 4)
#define NFUNCEN4_GPIO_01_SHIFT (4)
#define NFUNCEN4_GPIO_02 GENMASK(11, 8)
#define NFUNCEN4_GPIO_02_SHIFT (8)
#define NFUNCEN4_GPIO_03 GENMASK(15, 12)
#define NFUNCEN4_GPIO_03_SHIFT (12)
#define NFUNCEN4_GPIO_04 GENMASK(19, 16)
#define NFUNCEN4_GPIO_04_SHIFT (16)
#define NFUNCEN4_GPIO_05 GENMASK(23, 20)
#define NFUNCEN4_GPIO_05_SHIFT (20)
#define NFUNCEN4_GPIO_06 GENMASK(27, 24)
#define NFUNCEN4_GPIO_06_SHIFT (24)
#define NFUNCEN5_GPIO_10 GENMASK(3, 0)
#define NFUNCEN5_GPIO_10_SHIFT (0)
#define NFUNCEN5_GPIO_11 GENMASK(7, 4)
#define NFUNCEN5_GPIO_11_SHIFT (4)
#define NFUNCEN6_GPIO_12 GENMASK(19, 16)
#define NFUNCEN6_GPIO_12_SHIFT (16)
#define NIOCFG1_OFFSET (0x1614)
#define NIOCFG7_OFFSET (0x163C)
#define NIOEN7_OFFSET (0x173C)
#define GPIO_00 (0)
#define GPIO_01 (1)
#define GPIO_02 (2)
#define GPIO_03 (3)
#define GPIO_04 (4)
#define GPIO_05 (5)
#define GPIO_06 (6)
#define GPIO_10 (10)
#define GPIO_11 (11)
#define GPIO_12 (12)
#define GPIO_32 (32)
/* PCIe registers */
#define PCIE_OFFSET (0x20000)
#define PCIE_RANGE_UP_OFFSET_RgOffAddr(no) (PCIE_OFFSET + 0x6200 + (no*0x10))

View File

@ -71,6 +71,8 @@
* VERSION : 01-00-16
* 19 Oct 2021 : 1. Version update
* VERSION : 01-00-17
* 21 Oct 2021 : 1. Version update
* VERSION : 01-00-18
*/
#include <linux/clk-provider.h>
@ -103,7 +105,7 @@ static unsigned int tc956x_port1_interface = ENABLE_SGMII_INTERFACE;
unsigned int tc956x_port0_filter_phy_pause_frames = DISABLE;
unsigned int tc956x_port1_filter_phy_pause_frames = DISABLE;
static const struct tc956x_version tc956x_drv_version = {0, 1, 0, 0, 1, 7};
static const struct tc956x_version tc956x_drv_version = {0, 1, 0, 0, 1, 8};
/*
* This struct is used to associate PCI Function of MAC controller on a board,

View File

@ -72,6 +72,9 @@
* : 2. Adding MTL RX Overflow/packet miss count, TX underflow counts,Rx Watchdog value to ethtool statistics.
* : 3. Version update
* VERSION : 01-00-17
* 21 Oct 2021 : 1. Added support for GPIO configuration API
* : 2. Version update
* VERSION : 01-00-18
*/
#ifndef __TC956XMAC_H__
@ -120,7 +123,7 @@
#ifdef TC956X
#define TC956X_RESOURCE_NAME "tc956x_pci-eth"
#define DRV_MODULE_VERSION "V_01-00-17"
#define DRV_MODULE_VERSION "V_01-00-18"
#define TC956X_FW_MAX_SIZE (64*1024)
#define ATR_AXI4_SLV_BASE 0x0800
@ -703,5 +706,6 @@ static inline int tc956x_platform_suspend(struct tc956xmac_priv *priv) { return
static inline int tc956x_platform_resume(struct tc956xmac_priv *priv) { return 0; }
#endif
int tc956x_GPIO_OutputConfigPin(struct tc956xmac_priv *priv, u32 gpio_pin, u8 out_value);
#endif /* __TC956XMAC_H__ */

View File

@ -58,6 +58,8 @@
* VERSION : 01-00-13
* 23 Sep 2021 : 1. Capturing RBU status using MAC EVENT Interupt and updating to ethtool statistics for both S/W & IPA DMA channels
* VERSION : 01-00-14
* 21 Oct 2021 : 1. Added support for GPIO configuration API
* VERSION : 01-00-18
*/
#include <linux/clk.h>
@ -207,6 +209,117 @@ static uint16_t mdio_bus_id;
#define CONFIG_PARAM_NUM ARRAY_SIZE(config_param_list)
int tc956xmac_rx_parser_configuration(struct tc956xmac_priv *);
/**
* tc956x_GPIO_OutputConfigPin - to configure GPIO as output and write the value
* @priv: driver private structure
* @gpio_pin: GPIO pin number
* @out_value : value to write to the GPIO pin. Can be 0 or 1
* @remarks : Only GPIO0- GPIO06, GPI010-GPIO12 are allowed
*/
int tc956x_GPIO_OutputConfigPin(struct tc956xmac_priv *priv, u32 gpio_pin, u8 out_value)
{
u32 config, val;
/* Only GPIO0- GPIO06, GPI010-GPIO12 are allowed */
switch (gpio_pin) {
case GPIO_00:
val = readl(priv->ioaddr + NFUNCEN4_OFFSET);
val &= ~NFUNCEN4_GPIO_00;
val |= (NFUNCEN_FUNC0 << NFUNCEN4_GPIO_00_SHIFT);
writel(val, priv->ioaddr + NFUNCEN4_OFFSET);
break;
case GPIO_01:
val = readl(priv->ioaddr + NFUNCEN4_OFFSET);
val &= ~NFUNCEN4_GPIO_01;
val |= (NFUNCEN_FUNC0 << NFUNCEN4_GPIO_01_SHIFT);
writel(val, priv->ioaddr + NFUNCEN4_OFFSET);
break;
case GPIO_02:
val = readl(priv->ioaddr + NFUNCEN4_OFFSET);
val &= ~NFUNCEN4_GPIO_02;
val |= (NFUNCEN_FUNC0 << NFUNCEN4_GPIO_02_SHIFT);
writel(val, priv->ioaddr + NFUNCEN4_OFFSET);
break;
case GPIO_03:
val = readl(priv->ioaddr + NFUNCEN4_OFFSET);
val &= ~NFUNCEN4_GPIO_03;
val |= (NFUNCEN_FUNC0 << NFUNCEN4_GPIO_03_SHIFT);
writel(val, priv->ioaddr + NFUNCEN4_OFFSET);
break;
case GPIO_04:
val = readl(priv->ioaddr + NFUNCEN4_OFFSET);
val &= ~NFUNCEN4_GPIO_04;
val |= (NFUNCEN_FUNC0 << NFUNCEN4_GPIO_04_SHIFT);
writel(val, priv->ioaddr + NFUNCEN4_OFFSET);
break;
case GPIO_05:
val = readl(priv->ioaddr + NFUNCEN4_OFFSET);
val &= ~NFUNCEN4_GPIO_05;
val |= (NFUNCEN_FUNC0 << NFUNCEN4_GPIO_05_SHIFT);
writel(val, priv->ioaddr + NFUNCEN4_OFFSET);
break;
case GPIO_06:
val = readl(priv->ioaddr + NFUNCEN4_OFFSET);
val &= ~NFUNCEN4_GPIO_06;
val |= (NFUNCEN_FUNC0 << NFUNCEN4_GPIO_06_SHIFT);
writel(val, priv->ioaddr + NFUNCEN4_OFFSET);
break;
case GPIO_10:
val = readl(priv->ioaddr + NFUNCEN5_OFFSET);
val &= ~NFUNCEN5_GPIO_10;
val |= (NFUNCEN_FUNC0 << NFUNCEN5_GPIO_10_SHIFT);
writel(val, priv->ioaddr + NFUNCEN5_OFFSET);
break;
case GPIO_11:
val = readl(priv->ioaddr + NFUNCEN5_OFFSET);
val &= ~NFUNCEN5_GPIO_11;
val |= (NFUNCEN_FUNC0 << NFUNCEN5_GPIO_11_SHIFT);
writel(val, priv->ioaddr + NFUNCEN5_OFFSET);
break;
case GPIO_12:
val = readl(priv->ioaddr + NFUNCEN6_OFFSET);
val &= ~NFUNCEN6_GPIO_12;
val |= (NFUNCEN_FUNC0 << NFUNCEN6_GPIO_12_SHIFT);
writel(val, priv->ioaddr + NFUNCEN6_OFFSET);
break;
default :
netdev_err(priv->dev, "Invalid GPIO pin - %d\n", gpio_pin);
return -EPERM;
}
/* Write data to GPIO pin */
if(gpio_pin < GPIO_32) {
config = 1 << gpio_pin;
val = readl(priv->ioaddr + GPIOO0_OFFSET);
val &= ~config;
if(out_value)
val |= config;
writel(val, priv->ioaddr + GPIOO0_OFFSET);
} else {
config = 1 << (gpio_pin - GPIO_32);
val = readl(priv->ioaddr + GPIOO1_OFFSET);
val &= ~config;
if(out_value)
val |= config;
writel(val, priv->ioaddr + GPIOO1_OFFSET);
}
/* Configure the GPIO pin in output direction */
if(gpio_pin < GPIO_32) {
config = ~(1 << gpio_pin) ;
val = readl(priv->ioaddr + GPIOE0_OFFSET);
writel(val & config, priv->ioaddr + GPIOE0_OFFSET);
} else {
config = ~(1 << (gpio_pin - GPIO_32)) ;
val = readl(priv->ioaddr + GPIOE1_OFFSET);
writel(val & config, priv->ioaddr + GPIOE1_OFFSET);
}
return 0;
}
/**
* tc956xmac_verify_args - verify the driver parameters.
* Description: it checks the driver parameters and set a default in case of
@ -9863,6 +9976,7 @@ int tc956xmac_dvr_probe(struct device *device,
priv = netdev_priv(ndev);
priv->device = device;
priv->dev = ndev;
priv->ioaddr = res->addr;
ret = tc956x_platform_probe(priv, res);
if (ret) {
@ -9878,7 +9992,6 @@ int tc956xmac_dvr_probe(struct device *device,
tc956xmac_set_ethtool_ops(ndev);
priv->pause = pause;
priv->plat = plat_dat;
priv->ioaddr = res->addr;
#ifdef TC956X
priv->tc956x_SFR_pci_base_addr = res->tc956x_SFR_pci_base_addr;
priv->tc956x_SRAM_pci_base_addr = res->tc956x_SRAM_pci_base_addr;