Re: [PATCH v5 1/2] net: phy: DP83822 initial driver submission

2017-10-10 Thread Andrew F. Davis
On 10/10/2017 12:42 PM, Dan Murphy wrote:
> Add support for the TI  DP83822 10/100Mbit ethernet phy.
> 
> The DP83822 provides flexibility to connect to a MAC through a
> standard MII, RMII or RGMII interface.
> 
> In addition the DP83822 needs to be removed from the DP83848 driver
> as the WoL support is added here for this device.
> 
> Datasheet:
> http://www.ti.com/product/DP83822I/datasheet
> 
> Signed-off-by: Dan Murphy <dmur...@ti.com>
> ---


Looks much nicer now, thanks for dealing with my nitpicking :)

Acked-by: Andrew F. Davis <a...@ti.com>

> 
> v5 - Fixed bit mask, added config_init to set WOL register bits, fixed spacing
> issues, moved password storage under secure on if statement, and added INT_EN 
> bit
> setting for interrupt enable.
> https://www.mail-archive.com/netdev@vger.kernel.org/msg192495.html
> 
> v4 - Squash DP83822 removal patch into this patch -
> https://www.mail-archive.com/netdev@vger.kernel.org/msg192424.html
> 
> v3 - Fixed WoL indication bit and removed mutex for suspend/resume - 
> https://www.mail-archive.com/netdev@vger.kernel.org/msg191891.html and
> https://www.mail-archive.com/netdev@vger.kernel.org/msg191665.html
> 
> v2 - Updated per comments.  Removed unnessary parantheis, called 
> genphy_suspend/
> resume routines and then performing WoL changes, reworked sopass storage and 
> reduced
> the number of phy reads, and moved WOL_SECURE_ON - 
> https://www.mail-archive.com/netdev@vger.kernel.org/msg191392.html
> 
>  drivers/net/phy/Kconfig   |   5 +
>  drivers/net/phy/Makefile  |   1 +
>  drivers/net/phy/dp83822.c | 344 
> ++
>  drivers/net/phy/dp83848.c |   3 -
>  4 files changed, 350 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/net/phy/dp83822.c
> 
> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> index cd931cf9dcc2..8e78a482e09e 100644
> --- a/drivers/net/phy/Kconfig
> +++ b/drivers/net/phy/Kconfig
> @@ -277,6 +277,11 @@ config DAVICOM_PHY
>   ---help---
> Currently supports dm9161e and dm9131
>  
> +config DP83822_PHY
> + tristate "Texas Instruments DP83822 PHY"
> + ---help---
> +   Supports the DP83822 PHY.
> +
>  config DP83848_PHY
>   tristate "Texas Instruments DP83848 PHY"
>   ---help---
> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
> index 416df92fbf4f..df3b82ba8550 100644
> --- a/drivers/net/phy/Makefile
> +++ b/drivers/net/phy/Makefile
> @@ -55,6 +55,7 @@ obj-$(CONFIG_CICADA_PHY)+= cicada.o
>  obj-$(CONFIG_CORTINA_PHY)+= cortina.o
>  obj-$(CONFIG_DAVICOM_PHY)+= davicom.o
>  obj-$(CONFIG_DP83640_PHY)+= dp83640.o
> +obj-$(CONFIG_DP83822_PHY)+= dp83822.o
>  obj-$(CONFIG_DP83848_PHY)+= dp83848.o
>  obj-$(CONFIG_DP83867_PHY)+= dp83867.o
>  obj-$(CONFIG_FIXED_PHY)  += fixed_phy.o
> diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
> new file mode 100644
> index ..14335d14e9e4
> --- /dev/null
> +++ b/drivers/net/phy/dp83822.c
> @@ -0,0 +1,344 @@
> +/*
> + * Driver for the Texas Instruments DP83822 PHY
> + *
> + * Copyright (C) 2017 Texas Instruments Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DP83822_PHY_ID   0x2000a240
> +#define DP83822_DEVADDR  0x1f
> +
> +#define MII_DP83822_PHYSCR   0x11
> +#define MII_DP83822_MISR10x12
> +#define MII_DP83822_MISR20x13
> +#define MII_DP83822_RESET_CTRL   0x1f
> +
> +#define DP83822_HW_RESET BIT(15)
> +#define DP83822_SW_RESET BIT(14)
> +
> +/* PHYSCR Register Fields */
> +#define DP83822_PHYSCR_INT_OEBIT(0) /* Interrupt Output 
> Enable */
> +#define DP83822_PHYSCR_INTEN BIT(1) /* Interrupt Enable */
> +
> +/* MISR1 bits */
> +#define DP83822_RX_ERR_HF_INT_EN BIT(0)
> +#define DP83822_FALSE_CARRIER_HF_INT_EN  BIT(1)
> +#define DP83822_ANEG_COMPLETE_INT_EN BIT(2)
> +#define DP83822_DUP_MODE_CHANGE_INT_EN   BIT(3)
> +#define DP83822_SPEED_CHANGED_INT_EN BIT(4)
> +#define DP83822_LINK_S

Re: [PATCH v4 1/2] net: phy: DP83822 initial driver submission

2017-10-09 Thread Andrew F. Davis
On 10/09/2017 11:59 AM, Dan Murphy wrote:
> Add support for the TI  DP83822 10/100Mbit ethernet phy.
> 
> The DP83822 provides flexibility to connect to a MAC through a
> standard MII, RMII or RGMII interface.
> 
> In addition the DP83822 needs to be removed from the DP83848 driver
> as the WoL support is added here for this device.
> 
> Datasheet:
> http://www.ti.com/product/DP83822I/datasheet
> 
> Signed-off-by: Dan Murphy > ---
> 
> v4 - Squash DP83822 removal patch into this patch -
> https://www.mail-archive.com/netdev@vger.kernel.org/msg192424.html
> 
> v3 - Fixed WoL indication bit and removed mutex for suspend/resume - 
> https://www.mail-archive.com/netdev@vger.kernel.org/msg191891.html and
> https://www.mail-archive.com/netdev@vger.kernel.org/msg191665.html
> 
> v2 - Updated per comments.  Removed unnessary parantheis, called 
> genphy_suspend/
> resume routines and then performing WoL changes, reworked sopass storage and 
> reduced
> the number of phy reads, and moved WOL_SECURE_ON - 
> https://www.mail-archive.com/netdev@vger.kernel.org/msg191392.html
> 
>  drivers/net/phy/Kconfig   |   5 +
>  drivers/net/phy/Makefile  |   1 +
>  drivers/net/phy/dp83822.c | 302 
> ++
>  drivers/net/phy/dp83848.c |   3 -
>  4 files changed, 308 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/net/phy/dp83822.c
> 
> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> index cd931cf9dcc2..8e78a482e09e 100644
> --- a/drivers/net/phy/Kconfig
> +++ b/drivers/net/phy/Kconfig
> @@ -277,6 +277,11 @@ config DAVICOM_PHY
>   ---help---
> Currently supports dm9161e and dm9131
>  
> +config DP83822_PHY
> + tristate "Texas Instruments DP83822 PHY"
> + ---help---
> +   Supports the DP83822 PHY.
> +
>  config DP83848_PHY
>   tristate "Texas Instruments DP83848 PHY"
>   ---help---
> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
> index 416df92fbf4f..df3b82ba8550 100644
> --- a/drivers/net/phy/Makefile
> +++ b/drivers/net/phy/Makefile
> @@ -55,6 +55,7 @@ obj-$(CONFIG_CICADA_PHY)+= cicada.o
>  obj-$(CONFIG_CORTINA_PHY)+= cortina.o
>  obj-$(CONFIG_DAVICOM_PHY)+= davicom.o
>  obj-$(CONFIG_DP83640_PHY)+= dp83640.o
> +obj-$(CONFIG_DP83822_PHY)+= dp83822.o
>  obj-$(CONFIG_DP83848_PHY)+= dp83848.o
>  obj-$(CONFIG_DP83867_PHY)+= dp83867.o
>  obj-$(CONFIG_FIXED_PHY)  += fixed_phy.o
> diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
> new file mode 100644
> index ..de196dbc46cd
> --- /dev/null
> +++ b/drivers/net/phy/dp83822.c
> @@ -0,0 +1,302 @@
> +/*
> + * Driver for the Texas Instruments DP83822 PHY
> + *
> + * Copyright (C) 2017 Texas Instruments Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DP83822_PHY_ID   0x2000a240
> +#define DP83822_DEVADDR  0x1f
> +
> +#define MII_DP83822_MISR10x12
> +#define MII_DP83822_MISR20x13
> +#define MII_DP83822_RESET_CTRL   0x1f
> +
> +#define DP83822_HW_RESET BIT(15)
> +#define DP83822_SW_RESET BIT(14)
> +
> +/* MISR1 bits */
> +#define DP83822_RX_ERR_HF_INT_EN BIT(0)
> +#define DP83822_FALSE_CARRIER_HF_INT_EN  BIT(1)
> +#define DP83822_ANEG_COMPLETE_INT_EN BIT(2)
> +#define DP83822_DUP_MODE_CHANGE_INT_EN   BIT(3)
> +#define DP83822_SPEED_CHANGED_INT_EN BIT(4)
> +#define DP83822_LINK_STAT_INT_EN BIT(5)
> +#define DP83822_ENERGY_DET_INT_ENBIT(6)
> +#define DP83822_LINK_QUAL_INT_EN BIT(7)
> +
> +/* MISR2 bits */
> +#define DP83822_JABBER_DET_INT_ENBIT(0)
> +#define DP83822_WOL_PKT_INT_EN   BIT(1)
> +#define DP83822_SLEEP_MODE_INT_ENBIT(2)
> +#define DP83822_MDI_XOVER_INT_EN BIT(3)
> +#define DP83822_LB_FIFO_INT_EN   BIT(4)
> +#define DP83822_PAGE_RX_INT_EN   BIT(5)
> +#define DP83822_ANEG_ERR_INT_EN  BIT(6)
> +#define DP83822_EEE_ERROR_CHANGE_INT_EN  BIT(7)
> +
> +/* INT_STAT1 bits */
> +#define DP83822_WOL_INT_EN   BIT(4)
> +#define DP83822_WOL_INT_STAT BIT(12)
> +
> +#define MII_DP83822_RXSOP1   0x04a5
> +#define  MII_DP83822_RXSOP2  0x04a6
> +#define  MII_DP83822_RXSOP3  0x04a7
> +
> +/* WoL Registers */
> +#define  MII_DP83822_WOL_CFG 0x04a0
> +#define  MII_DP83822_WOL_STAT0x04a1
> +#define  MII_DP83822_WOL_DA1 0x04a2
> +#define  MII_DP83822_WOL_DA2 0x04a3

[PATCH] net: usb: asix88179_178a: Add support for the Belkin B2B128

2017-06-26 Thread Andrew F. Davis
The Belkin B2B128 is a USB 3.0 Hub + Gigabit Ethernet Adapter, the
Ethernet adapter uses the ASIX AX88179 USB 3.0 to Gigabit Ethernet
chip supported by this driver, add the USB ID for the same.

This patch is based on work by Geoffrey Tran <geoffrey.t...@gmail.com>
who has indicated they would like this upstreamed by someone more
familiar with the upstreaming process.

Signed-off-by: Andrew F. Davis <a...@ti.com>
---
 drivers/net/usb/ax88179_178a.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 51cf60092a18..4037ab27734a 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1722,6 +1722,18 @@ static const struct driver_info lenovo_info = {
.tx_fixup = ax88179_tx_fixup,
 };
 
+static const struct driver_info belkin_info = {
+   .description = "Belkin USB Ethernet Adapter",
+   .bind   = ax88179_bind,
+   .unbind = ax88179_unbind,
+   .status = ax88179_status,
+   .link_reset = ax88179_link_reset,
+   .reset  = ax88179_reset,
+   .flags  = FLAG_ETHER | FLAG_FRAMING_AX,
+   .rx_fixup = ax88179_rx_fixup,
+   .tx_fixup = ax88179_tx_fixup,
+};
+
 static const struct usb_device_id products[] = {
 {
/* ASIX AX88179 10/100/1000 */
@@ -1751,6 +1763,10 @@ static const struct usb_device_id products[] = {
/* Lenovo OneLinkDock Gigabit LAN */
USB_DEVICE(0x17ef, 0x304b),
.driver_info = (unsigned long)_info,
+}, {
+   /* Belkin B2B128 USB 3.0 Hub + Gigabit Ethernet Adapter */
+   USB_DEVICE(0x050d, 0x0128),
+   .driver_info = (unsigned long)_info,
 },
{ },
 };
-- 
2.13.0



Re: [PATCH] net: phy: dp83848: Support ethernet pause frames

2016-12-02 Thread Andrew F. Davis
On 12/02/2016 08:22 AM, Jesper Nilsson wrote:
> According to the documentation, the PHYs supported by this driver
> can also support pause frames. Announce this to be so.
> Tested with a TI83822I.
> 

Looks like all PHYs supported by this driver do, so:

Acked-by: Andrew F. Davis <a...@ti.com>

> Signed-off-by: Jesper Nilsson <jesper.nils...@axis.com>
> ---
>  drivers/net/phy/dp83848.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
> index 800b39f..6e4117f 100644
> --- a/drivers/net/phy/dp83848.c
> +++ b/drivers/net/phy/dp83848.c
> @@ -88,7 +88,8 @@ MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
>   .phy_id = _id,  \
>   .phy_id_mask= 0xfff0,   \
>   .name   = _name,\
> - .features   = PHY_BASIC_FEATURES,   \
> + .features   = (PHY_BASIC_FEATURES | \
> + SUPPORTED_Pause | SUPPORTED_Asym_Pause),\

Aligning these may look nicer though.

>   .flags  = PHY_HAS_INTERRUPT,\
>   \
>   .soft_reset = genphy_soft_reset,\
> 


Re: [PATCH v2 0/2] net: ethernet: ti: cpsw: delete rx_descs property

2016-06-13 Thread Andrew F. Davis
On 06/13/2016 03:22 AM, Mugunthan V N wrote:
> On Saturday 11 June 2016 04:34 AM, Schuyler Patton wrote:
>>
>>
>> On 06/08/2016 07:03 PM, Ivan Khoronzhuk wrote:
>>>
>>>
>>> On 09.06.16 02:11, Schuyler Patton wrote:


 On 06/08/2016 09:06 AM, Ivan Khoronzhuk wrote:
>
>
> On 08.06.16 17:01, Ivan Khoronzhuk wrote:
>> Hi Schuyer,
>>
>> On 07.06.16 18:26, Schuyler Patton wrote:
>>> Hi,
>>>
>>> On 06/07/2016 08:59 AM, Ivan Khoronzhuk wrote:
 There is no reason in rx_descs property because davinici_cpdma
 driver splits pool of descriptors equally between tx and rx
 channels.
 So, this patch series makes driver to use available number of
 descriptors for rx channels.
>>>
>>> I agree with the idea of consolidating how the descriptors are
>>> defined because of
>>> the two variable components, number and size of the pool can be
>>> confusing to
>>> end users. I would like to request to change how it is being
>>> proposed here.
>>>
>>> I think the number of descriptors should be left in the device
>>> tree source file as
>>> is and remove the BD size variable and have the driver calculate
>>> the size of the
>>> pool necessary to support the descriptor request. From an user
>>> perspective it is
>>> easier I think to be able to list the number of descriptors
>>> necessary vs. the size
>>> of the pool.
>>>
>>> Since the patch series points out how it is used so in the driver
>>> so to make that
>>> consistent is perhaps change rx_descs to total_descs.
>>>
>>> Regards,
>>> Schuyler
>>
>> The DT entry for cpsw doesn't have property for size of the pool.
>> It contains only BD ram size, if you mean this. The size of the
>> pool is
>> software decision. Current version of DT entry contain only rx desc
>> number.
>> That is not correct, as it depends on the size of the descriptor,
>> which is also
>> h/w parameter. The DT entry has to describe only h/w part and
>> shouldn't contain
>> driver implementation details, and I'm looking on it from this
>> perspective.
>>
>> Besides, rx_descs describes only rx number of descriptors, that are
>> taken from
>> the same pool as tx descriptors, and setting rx desc to some new
>> value doesn't
>> mean that rest of them are freed for tx. Also, I'm going to send
>> series that
>> adds multi channel support to the driver, and in this case,
>> splitting of the
>> pool will be more sophisticated than now, after what setting those
>> parameters
>> for user (he should do this via device tree) can be even more
>> confusing. But,
> should -> shouldn't
>
>> as it's supposed, it's software decision that shouldn't leak to the
>> DT.

 If this rx-desc field is removed how will the number of descriptors
 be set?

 This field has been used to increase the number of descriptors so high
 volume short packets are not dropped due to descriptor exhaustion.
 The current
 default number of 64 rx descriptors is too low for gigabit networks.
 Some users
 have a strong requirement for zero loss of UDP packets setting this
 field to a
 larger number and setting the descriptors off-chip was a means to solve
 the problem.
>>> The current implementation of cpdma driver splits descs num on 2 parts
>>> equally.
>>> Total number = 256, then 128 reserved for rx and 128 for tx, but
>>> setting this to
>>> 64, simply limits usage of reserved rx descriptors to 64, so that:
>>> 64 rx descs, 128 tx descs and 64 are always present in the pool but
>>> cannot be used,
>>> (as new rx descriptor is allocated only after previous was freed).
>>> That means, 64 rx descs are unused. In case of rx descriptor
>>> exhaustion, an user can
>>> set rx_descs to 128, for instance, in this case all descriptors will
>>> be in use, but then question,
>>> why intentionally limit number of rx descs, anyway rest 64 descs
>>> cannot be used for other
>>> purposes. In case of this patch, all rx descs are in use, and no need
>>> to correct number
>>> of rx descs anymore, use all of themand it doesn't have impact on
>>> performance, as
>>> anyway, bunch of rx descs were simply limited by DT and unused. So,
>>> probably, there is no
>>> reason to worry about that.
>>
>> When we see this issue we set the descriptors to DDR and put a large number
>> in the desc count. unfortunately I wish I could provide a number,
>> usually the issue
>> is a volume burst of short UDP packets.
>>
>>>
>>> PS:
>>> It doesn't concern this patch, but, which PPS makes rx descs to be
>>> exhausted?...
>>> (In this case "desc_alloc_fail" counter contains some value for rx
>>> channel,
>>> and can be read with "ethtool -S eth0". Also, the user will be WARNed
>>> ON by the driver)
>>>
>>> it's interesting to test it, I'm 

Re: [PATCH v2 net-next] net: ethernet: enc28j60: add device tree support

2016-04-25 Thread Andrew F. Davis
On 04/25/2016 12:46 PM, Michael Heimpold wrote:
> Hi,
> 
> Am Monday 25 April 2016, 10:39:41 schrieben Sie:
>> On 04/24/2016 04:28 PM, Michael Heimpold wrote:
>>> -   eth_hw_addr_random(dev);
>>> +
>>> +   macaddr = of_get_mac_address(spi->dev.of_node);
>>> +   if (macaddr)
>>
>> You should also check if it is a valid MAC for Ethernet, recommend:
>>
>> if (macaddr && is_valid_ether_addr(macaddr))
>>
> 
> But of_get_mac_address already takes care of this, see
> http://lxr.free-electrons.com/source/drivers/of/of_net.c#L45
> Also it already checks whether spi->dev.of_node is populated at all.
> It returns NULL in both error cases.
> So I prefered to omit both test here.
> 

Ah, missed that, no problem here then.

Hmm, I wonder how many other drivers then do this check needlessly..
Time to fire-up Coccinelle :)

Andrew


Re: [PATCH v2 net-next] net: ethernet: enc28j60: add device tree support

2016-04-25 Thread Andrew F. Davis
On 04/24/2016 04:28 PM, Michael Heimpold wrote:
> The following patch adds the required match table for device tree support
> (and while at, fix the indent). It's also possible to specify the
> MAC address in the DT blob.
> 
> Also add the corresponding binding documentation file.
> 
> Signed-off-by: Michael Heimpold 
> ---
> 
> v2: * took care of Arnd Bergmann's review comments
>   - allow to specify MAC address via DT
>   - unconditionally define DT id table
> * increased the driver version minor number
> * driver author's email address bounces, removed from address list
> 
>  .../devicetree/bindings/net/microchip-enc28j60.txt | 50 
> ++
>  drivers/net/ethernet/microchip/enc28j60.c  | 20 +++--
>  2 files changed, 67 insertions(+), 3 deletions(-)
>  create mode 100644 
> Documentation/devicetree/bindings/net/microchip-enc28j60.txt
> 
> diff --git a/Documentation/devicetree/bindings/net/microchip-enc28j60.txt 
> b/Documentation/devicetree/bindings/net/microchip-enc28j60.txt
> new file mode 100644
> index 000..847a97b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/microchip-enc28j60.txt
> @@ -0,0 +1,50 @@
> +* Microchip ENC28J60
> +
> +This is a standalone 10 MBit ethernet controller with SPI interface.
> +
> +For each device connected to a SPI bus, define a child node within
> +the SPI master node.
> +
> +Required properties:
> +- compatible: Should be "microchip,enc28j60"
> +- reg: Specify the SPI chip select the ENC28J60 is wired to
> +- interrupts: Specify the interrupt and interrupt type (usually falling edge)
> +
> +Optional properties:
> +- interrupt-parent: Specify the pHandle of the source interrupt
> +- spi-max-frequency: Maximum frequency of the SPI bus when accessing the 
> ENC28J60.
> +  According to the ENC28J80 datasheet, the chip allows a maximum of 20 MHz, 
> however,
> +  board designs may need to limit this value.
> +- local-mac-address: See ethernet.txt in the same directory.
> +
> +
> +Example (for NXP i.MX28 with pin control stuff for GPIO irq):
> +
> +ssp2: ssp@80014000 {
> +compatible = "fsl,imx28-spi";
> +pinctrl-names = "default";
> +pinctrl-0 = <_pins_b _sck_cfg>;
> +status = "okay";
> +
> +enc28j60: ethernet@0 {
> +compatible = "microchip,enc28j60";
> +pinctrl-names = "default";
> +pinctrl-0 = <_pins>;
> +reg = <0>;
> +interrupt-parent = <>;
> +interrupts = <3 IRQ_TYPE_EDGE_FALLING>;
> +spi-max-frequency = <1200>;
> +};
> +};
> +
> +pinctrl@80018000 {
> +enc28j60_pins: enc28j60_pins@0 {
> +reg = <0>;
> +fsl,pinmux-ids = <
> +MX28_PAD_AUART0_RTS__GPIO_3_3/* 
> Interrupt */
> +>;
> +fsl,drive-strength = ;
> +fsl,voltage = ;
> +fsl,pull-up = ;
> +};
> +};
> diff --git a/drivers/net/ethernet/microchip/enc28j60.c 
> b/drivers/net/ethernet/microchip/enc28j60.c
> index b723622..7066954 100644
> --- a/drivers/net/ethernet/microchip/enc28j60.c
> +++ b/drivers/net/ethernet/microchip/enc28j60.c
> @@ -28,11 +28,12 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "enc28j60_hw.h"
>  
>  #define DRV_NAME "enc28j60"
> -#define DRV_VERSION  "1.01"
> +#define DRV_VERSION  "1.02"
>  
>  #define SPI_OPLEN1
>  
> @@ -1548,6 +1549,7 @@ static int enc28j60_probe(struct spi_device *spi)
>  {
>   struct net_device *dev;
>   struct enc28j60_net *priv;
> + const void *macaddr;
>   int ret = 0;
>  
>   if (netif_msg_drv())
> @@ -1579,7 +1581,12 @@ static int enc28j60_probe(struct spi_device *spi)
>   ret = -EIO;
>   goto error_irq;
>   }
> - eth_hw_addr_random(dev);
> +
> + macaddr = of_get_mac_address(spi->dev.of_node);
> + if (macaddr)

You should also check if it is a valid MAC for Ethernet, recommend:

if (macaddr && is_valid_ether_addr(macaddr))

> + ether_addr_copy(dev->dev_addr, macaddr);
> + else
> + eth_hw_addr_random(dev);
>   enc28j60_set_hw_macaddr(dev);
>  
>   /* Board setup must set the relevant edge trigger type;
> @@ -1634,9 +1641,16 @@ static int enc28j60_remove(struct spi_device *spi)
>   return 0;
>  }
>  
> +static const struct of_device_id enc28j60_dt_ids[] = {
> + { .compatible = "microchip,enc28j60" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, enc28j60_dt_ids);
> +
>  static struct spi_driver enc28j60_driver = {
>   .driver = {
> -.name = DRV_NAME,
> + .name = DRV_NAME,
> + .of_match_table = 

[PATCH] net: phy: dp83848: Fix sysfs naming collision warning

2016-02-17 Thread Andrew F. Davis
Files in sysfs are created using the name from the phy_driver struct,
when two names are the same we may get a duplicate filename warning,
fix this.

Reported-by: kernel test robot <ying.hu...@linux.intel.com>
Signed-off-by: Andrew F. Davis <a...@ti.com>
---
 drivers/net/phy/dp83848.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
index 556904f..03d54c4 100644
--- a/drivers/net/phy/dp83848.c
+++ b/drivers/net/phy/dp83848.c
@@ -103,7 +103,7 @@ MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
 
 static struct phy_driver dp83848_driver[] = {
DP83848_PHY_DRIVER(TI_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"),
-   DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"),
+   DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "NS DP83848C 10/100 Mbps PHY"),
DP83848_PHY_DRIVER(TLK10X_PHY_ID, "TI TLK10X 10/100 Mbps PHY"),
 };
 module_phy_driver(dp83848_driver);
-- 
2.7.1



Re: [PATCH v2 2/5] net: phy: dp83848: Add PHY ID for TI version of DP83848C

2016-02-17 Thread Andrew F. Davis

On 02/07/2016 11:47 AM, Andrew F. Davis wrote:

After acquiring National Semiconductor, TI appears to have
changed the Vendor Model Number for the DP83848C PHYs,
add this new ID to supported IDs.

Signed-off-by: Andrew F. Davis <a...@ti.com>
---
  drivers/net/phy/dp83848.c | 9 ++---
  1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
index 4e78f54..d4686d5f 100644
--- a/drivers/net/phy/dp83848.c
+++ b/drivers/net/phy/dp83848.c
@@ -16,7 +16,8 @@
  #include 
  #include 

-#define DP83848_PHY_ID 0x20005c90
+#define TI_DP83848C_PHY_ID 0x20005ca0
+#define NS_DP83848C_PHY_ID 0x20005c90

  /* Registers */
  #define DP83848_MICR  0x11
@@ -65,7 +66,8 @@ static int dp83848_config_intr(struct phy_device *phydev)
  }

  static struct mdio_device_id __maybe_unused dp83848_tbl[] = {
-   { DP83848_PHY_ID, 0xfff0 },
+   { TI_DP83848C_PHY_ID, 0xfff0 },
+   { NS_DP83848C_PHY_ID, 0xfff0 },
{ }
  };
  MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
@@ -91,7 +93,8 @@ MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
}

  static struct phy_driver dp83848_driver[] = {
-   DP83848_PHY_DRIVER(DP83848_PHY_ID, "TI DP83848 10/100 Mbps PHY"),
+   DP83848_PHY_DRIVER(TI_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"),
+   DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"),


This seems to be causing a warning about duplicate file names (driver name in
sysfs), so the bottom one can probably s/TI/NS, can this be changed in-tree
before the merge or should I submit a patch?

Andrew


  };
  module_phy_driver(dp83848_driver);




Re: [PATCH] net: phy: dp83848: Add support for TI TLK10x Ethernet PHYs

2016-02-07 Thread Andrew F. Davis

On 02/06/2016 03:25 PM, Florian Fainelli wrote:

Le 05/02/2016 15:13, Andrew F. Davis a écrit :

The TI TLK10x Ethernet PHYs are similar in the interrupt relevant
registers and so are compatible with the DP83848x devices already
supported. Add these and re-order code to support additional PHYs.


This looks fine, but this could also be broken down into 3 commits:

- one which adds the macro to add new PHY entries
- one which renames DP83848_PHY_ID to DP83848C_PHY_ID
- one which factors out the interrupt enable mask



No problem, will do.



Signed-off-by: Andrew F. Davis <a...@ti.com>
---
  drivers/net/phy/dp83848.c | 89 ---
  1 file changed, 53 insertions(+), 36 deletions(-)

diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
index 5e14e62..bc88259 100644
--- a/drivers/net/phy/dp83848.c
+++ b/drivers/net/phy/dp83848.c
@@ -1,7 +1,8 @@
  /*
   * Driver for the Texas Instruments DP83848 PHY
   *
- * Copyright (C) 2015 Texas Instruments Inc.
+ * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/
+ * Andrew F. Davis <a...@ti.com>


We have the git changelog to know who added changes to the driver, you
can drop that specific change and just bump the copyright year.


I was the original author and forgot to add this, just like the consistency
with other drivers with named authors, but not a big deal so I can drop that.

Andrew


--
Florian



[PATCH v2 0/5] net: phy: dp83848: Add support for TI TLK10x Ethernet PHYs

2016-02-07 Thread Andrew F. Davis
Hello all,

This series is [0] split into its logical components.

Thanks,
Andrew

[0] http://www.spinics.net/lists/netdev/msg363106.html

Andrew F. Davis (5):
  net: phy: dp83848: Add macro for dp83848 compatible devices
  net: phy: dp83848: Add PHY ID for TI version of DP83848C
  net: phy: dp83848: Reorganize code for readability and safety
  net: phy: dp83848: Add support for TI TLK10x Ethernet PHYs
  net: phy: dp83848: Add comments for register definitions

 drivers/net/phy/dp83848.c | 88 ---
 1 file changed, 52 insertions(+), 36 deletions(-)

-- 
2.7.0



[PATCH v2 5/5] net: phy: dp83848: Add comments for register definitions

2016-02-07 Thread Andrew F. Davis
Signed-off-by: Andrew F. Davis <a...@ti.com>
---
 drivers/net/phy/dp83848.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
index f897989..556904f 100644
--- a/drivers/net/phy/dp83848.c
+++ b/drivers/net/phy/dp83848.c
@@ -21,8 +21,8 @@
 #define TLK10X_PHY_ID  0x2000a210
 
 /* Registers */
-#define DP83848_MICR   0x11
-#define DP83848_MISR   0x12
+#define DP83848_MICR   0x11 /* MII Interrupt Control Register 
*/
+#define DP83848_MISR   0x12 /* MII Interrupt Status Register */
 
 /* MICR Register Fields */
 #define DP83848_MICR_INT_OEBIT(0) /* Interrupt Output Enable */
-- 
2.7.0



[PATCH v2 2/5] net: phy: dp83848: Add PHY ID for TI version of DP83848C

2016-02-07 Thread Andrew F. Davis
After acquiring National Semiconductor, TI appears to have
changed the Vendor Model Number for the DP83848C PHYs,
add this new ID to supported IDs.

Signed-off-by: Andrew F. Davis <a...@ti.com>
---
 drivers/net/phy/dp83848.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
index 4e78f54..d4686d5f 100644
--- a/drivers/net/phy/dp83848.c
+++ b/drivers/net/phy/dp83848.c
@@ -16,7 +16,8 @@
 #include 
 #include 
 
-#define DP83848_PHY_ID 0x20005c90
+#define TI_DP83848C_PHY_ID 0x20005ca0
+#define NS_DP83848C_PHY_ID 0x20005c90
 
 /* Registers */
 #define DP83848_MICR   0x11
@@ -65,7 +66,8 @@ static int dp83848_config_intr(struct phy_device *phydev)
 }
 
 static struct mdio_device_id __maybe_unused dp83848_tbl[] = {
-   { DP83848_PHY_ID, 0xfff0 },
+   { TI_DP83848C_PHY_ID, 0xfff0 },
+   { NS_DP83848C_PHY_ID, 0xfff0 },
{ }
 };
 MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
@@ -91,7 +93,8 @@ MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
}
 
 static struct phy_driver dp83848_driver[] = {
-   DP83848_PHY_DRIVER(DP83848_PHY_ID, "TI DP83848 10/100 Mbps PHY"),
+   DP83848_PHY_DRIVER(TI_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"),
+   DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"),
 };
 module_phy_driver(dp83848_driver);
 
-- 
2.7.0



[PATCH v2 4/5] net: phy: dp83848: Add support for TI TLK10x Ethernet PHYs

2016-02-07 Thread Andrew F. Davis
The TI TLK10x Ethernet PHYs are similar in the interrupt relevant
registers and so are compatible with the DP83848x devices already
supported.

Signed-off-by: Andrew F. Davis <a...@ti.com>
---
 drivers/net/phy/dp83848.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
index 20d3b9d..f897989 100644
--- a/drivers/net/phy/dp83848.c
+++ b/drivers/net/phy/dp83848.c
@@ -18,6 +18,7 @@
 
 #define TI_DP83848C_PHY_ID 0x20005ca0
 #define NS_DP83848C_PHY_ID 0x20005c90
+#define TLK10X_PHY_ID  0x2000a210
 
 /* Registers */
 #define DP83848_MICR   0x11
@@ -75,6 +76,7 @@ static int dp83848_config_intr(struct phy_device *phydev)
 static struct mdio_device_id __maybe_unused dp83848_tbl[] = {
{ TI_DP83848C_PHY_ID, 0xfff0 },
{ NS_DP83848C_PHY_ID, 0xfff0 },
+   { TLK10X_PHY_ID, 0xfff0 },
{ }
 };
 MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
@@ -102,6 +104,7 @@ MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
 static struct phy_driver dp83848_driver[] = {
DP83848_PHY_DRIVER(TI_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"),
DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY"),
+   DP83848_PHY_DRIVER(TLK10X_PHY_ID, "TI TLK10X 10/100 Mbps PHY"),
 };
 module_phy_driver(dp83848_driver);
 
-- 
2.7.0



[PATCH v2 3/5] net: phy: dp83848: Reorganize code for readability and safety

2016-02-07 Thread Andrew F. Davis
Reorganize code by moving the desired interrupt mask definition
out of function. Also rearrange the enable/disable interrupt function
to prevent accidental over-writing of values in registers.

Signed-off-by: Andrew F. Davis <a...@ti.com>
---
 drivers/net/phy/dp83848.c | 33 -
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
index d4686d5f..20d3b9d 100644
--- a/drivers/net/phy/dp83848.c
+++ b/drivers/net/phy/dp83848.c
@@ -37,6 +37,12 @@
 #define DP83848_MISR_ED_INT_EN BIT(6) /* Energy detect */
 #define DP83848_MISR_LQM_INT_ENBIT(7) /* Link Quality Monitor 
*/
 
+#define DP83848_INT_EN_MASK\
+   (DP83848_MISR_ANC_INT_EN |  \
+DP83848_MISR_DUP_INT_EN |  \
+DP83848_MISR_SPD_INT_EN |  \
+DP83848_MISR_LINK_INT_EN)
+
 static int dp83848_ack_interrupt(struct phy_device *phydev)
 {
int err = phy_read(phydev, DP83848_MISR);
@@ -46,23 +52,24 @@ static int dp83848_ack_interrupt(struct phy_device *phydev)
 
 static int dp83848_config_intr(struct phy_device *phydev)
 {
-   int err;
+   int control, ret;
+
+   control = phy_read(phydev, DP83848_MICR);
+   if (control < 0)
+   return control;
 
if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
-   err = phy_write(phydev, DP83848_MICR,
-   DP83848_MICR_INT_OE |
-   DP83848_MICR_INTEN);
-   if (err < 0)
-   return err;
-
-   return phy_write(phydev, DP83848_MISR,
-DP83848_MISR_ANC_INT_EN |
-DP83848_MISR_DUP_INT_EN |
-DP83848_MISR_SPD_INT_EN |
-DP83848_MISR_LINK_INT_EN);
+   control |= DP83848_MICR_INT_OE;
+   control |= DP83848_MICR_INTEN;
+
+   ret = phy_write(phydev, DP83848_MISR, DP83848_INT_EN_MASK);
+   if (ret < 0)
+   return ret;
+   } else {
+   control &= ~DP83848_MICR_INTEN;
}
 
-   return phy_write(phydev, DP83848_MICR, 0x0);
+   return phy_write(phydev, DP83848_MICR, control);
 }
 
 static struct mdio_device_id __maybe_unused dp83848_tbl[] = {
-- 
2.7.0



[PATCH v2 1/5] net: phy: dp83848: Add macro for dp83848 compatible devices

2016-02-07 Thread Andrew F. Davis
Add a helper macro for defining dp83848 compatible phy devices.
Update copyright info.

Signed-off-by: Andrew F. Davis <a...@ti.com>
---
 drivers/net/phy/dp83848.c | 41 ++---
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
index 5e14e62..4e78f54 100644
--- a/drivers/net/phy/dp83848.c
+++ b/drivers/net/phy/dp83848.c
@@ -1,7 +1,7 @@
 /*
  * Driver for the Texas Instruments DP83848 PHY
  *
- * Copyright (C) 2015 Texas Instruments Inc.
+ * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -70,25 +70,28 @@ static struct mdio_device_id __maybe_unused dp83848_tbl[] = 
{
 };
 MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
 
-static struct phy_driver dp83848_driver[] = {
-   {
-   .phy_id = DP83848_PHY_ID,
-   .phy_id_mask= 0xfff0,
-   .name   = "TI DP83848",
-   .features   = PHY_BASIC_FEATURES,
-   .flags  = PHY_HAS_INTERRUPT,
-
-   .soft_reset = genphy_soft_reset,
-   .config_init= genphy_config_init,
-   .suspend= genphy_suspend,
-   .resume = genphy_resume,
-   .config_aneg= genphy_config_aneg,
-   .read_status= genphy_read_status,
+#define DP83848_PHY_DRIVER(_id, _name) \
+   {   \
+   .phy_id = _id,  \
+   .phy_id_mask= 0xfff0,   \
+   .name   = _name,\
+   .features   = PHY_BASIC_FEATURES,   \
+   .flags  = PHY_HAS_INTERRUPT,\
+   \
+   .soft_reset = genphy_soft_reset,\
+   .config_init= genphy_config_init,   \
+   .suspend= genphy_suspend,   \
+   .resume = genphy_resume,\
+   .config_aneg= genphy_config_aneg,   \
+   .read_status= genphy_read_status,   \
+   \
+   /* IRQ related */   \
+   .ack_interrupt  = dp83848_ack_interrupt,\
+   .config_intr= dp83848_config_intr,  \
+   }
 
-   /* IRQ related */
-   .ack_interrupt  = dp83848_ack_interrupt,
-   .config_intr= dp83848_config_intr,
-   },
+static struct phy_driver dp83848_driver[] = {
+   DP83848_PHY_DRIVER(DP83848_PHY_ID, "TI DP83848 10/100 Mbps PHY"),
 };
 module_phy_driver(dp83848_driver);
 
-- 
2.7.0



[PATCH] net: phy: dp83848: Add support for TI TLK10x Ethernet PHYs

2016-02-05 Thread Andrew F. Davis
The TI TLK10x Ethernet PHYs are similar in the interrupt relevant
registers and so are compatible with the DP83848x devices already
supported. Add these and re-order code to support additional PHYs.

Signed-off-by: Andrew F. Davis <a...@ti.com>
---
 drivers/net/phy/dp83848.c | 89 ---
 1 file changed, 53 insertions(+), 36 deletions(-)

diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
index 5e14e62..bc88259 100644
--- a/drivers/net/phy/dp83848.c
+++ b/drivers/net/phy/dp83848.c
@@ -1,7 +1,8 @@
 /*
  * Driver for the Texas Instruments DP83848 PHY
  *
- * Copyright (C) 2015 Texas Instruments Inc.
+ * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/
+ * Andrew F. Davis <a...@ti.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -16,11 +17,13 @@
 #include 
 #include 
 
-#define DP83848_PHY_ID 0x20005c90
+#define DP83848C_PHY_ID0x20005c90
+#define DP83848I_PHY_ID0x20005ca0
+#define TLK10X_PHY_ID  0x2000a210
 
 /* Registers */
-#define DP83848_MICR   0x11
-#define DP83848_MISR   0x12
+#define DP83848_MICR   0x11 /* MII Interrupt Control Register 
*/
+#define DP83848_MISR   0x12 /* MII Interrupt Status Register */
 
 /* MICR Register Fields */
 #define DP83848_MICR_INT_OEBIT(0) /* Interrupt Output Enable */
@@ -36,6 +39,12 @@
 #define DP83848_MISR_ED_INT_EN BIT(6) /* Energy detect */
 #define DP83848_MISR_LQM_INT_ENBIT(7) /* Link Quality Monitor 
*/
 
+#define DP83848_INT_EN_MASK\
+   (DP83848_MISR_ANC_INT_EN |  \
+DP83848_MISR_DUP_INT_EN |  \
+DP83848_MISR_SPD_INT_EN |  \
+DP83848_MISR_LINK_INT_EN)
+
 static int dp83848_ack_interrupt(struct phy_device *phydev)
 {
int err = phy_read(phydev, DP83848_MISR);
@@ -45,50 +54,58 @@ static int dp83848_ack_interrupt(struct phy_device *phydev)
 
 static int dp83848_config_intr(struct phy_device *phydev)
 {
-   int err;
+   int control, ret;
+
+   control = phy_read(phydev, DP83848_MICR);
+   if (control < 0)
+   return control;
 
if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
-   err = phy_write(phydev, DP83848_MICR,
-   DP83848_MICR_INT_OE |
-   DP83848_MICR_INTEN);
-   if (err < 0)
-   return err;
-
-   return phy_write(phydev, DP83848_MISR,
-DP83848_MISR_ANC_INT_EN |
-DP83848_MISR_DUP_INT_EN |
-DP83848_MISR_SPD_INT_EN |
-DP83848_MISR_LINK_INT_EN);
+   control |= DP83848_MICR_INT_OE;
+   control |= DP83848_MICR_INTEN;
+
+   ret = phy_write(phydev, DP83848_MISR, DP83848_INT_EN_MASK);
+   if (ret < 0)
+   return ret;
+   } else {
+   control &= ~DP83848_MICR_INTEN;
}
 
-   return phy_write(phydev, DP83848_MICR, 0x0);
+   return phy_write(phydev, DP83848_MICR, control);
 }
 
 static struct mdio_device_id __maybe_unused dp83848_tbl[] = {
-   { DP83848_PHY_ID, 0xfff0 },
+   { DP83848C_PHY_ID, 0xfff0 },
+   { DP83848I_PHY_ID, 0xfff0 },
+   { TLK10X_PHY_ID, 0xfff0 },
{ }
 };
 MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
 
+#define DP83848_PHY_DRIVER(_id, _name) \
+   {   \
+   .phy_id = _id,  \
+   .phy_id_mask= 0xfff0,   \
+   .name   = _name,\
+   .features   = PHY_BASIC_FEATURES,   \
+   .flags  = PHY_HAS_INTERRUPT,\
+   \
+   .soft_reset = genphy_soft_reset,\
+   .config_init= genphy_config_init,   \
+   .suspend= genphy_suspend,   \
+   .resume = genphy_resume,\
+   .config_aneg= genphy_config_aneg,   \
+   .read_status= genphy_read_status,   \
+   \
+   /* IRQ related */   \
+   .ack_interrupt  = dp83848_ack_interrupt,\
+   .config_intr= dp83848_config_intr,  \
+   }
+
 static struct phy_driver dp83848_driver[] = {
-   {
-   .phy_id = DP83848_PHY_ID,

[PATCH] net: phy: dp83848: Add TI DP83848 Ethernet PHY

2015-10-20 Thread Andrew F. Davis
Add support for the TI DP83848 Ethernet PHY device.

The DP83848 is a highly reliable, feature rich, IEEE 802.3 compliant
single port 10/100 Mb/s Ethernet Physical Layer Transceiver supporting
the MII and RMII interfaces.

Signed-off-by: Andrew F. Davis <a...@ti.com>
Signed-off-by: Dan Murphy <dmur...@ti.com>
---
 drivers/net/phy/Kconfig   |  5 +++
 drivers/net/phy/Makefile  |  1 +
 drivers/net/phy/dp83848.c | 99 +++
 3 files changed, 105 insertions(+)
 create mode 100644 drivers/net/phy/dp83848.c

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index c5ad98a..12fa29a 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -122,6 +122,11 @@ config MICREL_PHY
---help---
  Supports the KSZ9021, VSC8201, KS8001 PHYs.
 
+config DP83848_PHY
+   tristate "Driver for Texas Instruments DP83848 PHY"
+   ---help---
+ Supports the DP83848 PHY.
+
 config DP83867_PHY
tristate "Drivers for Texas Instruments DP83867 Gigabit PHY"
---help---
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 87f079c..b748224 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_MDIO_BITBANG)+= mdio-bitbang.o
 obj-$(CONFIG_MDIO_GPIO)+= mdio-gpio.o
 obj-$(CONFIG_NATIONAL_PHY) += national.o
 obj-$(CONFIG_DP83640_PHY)  += dp83640.o
+obj-$(CONFIG_DP83848_PHY)  += dp83848.o
 obj-$(CONFIG_DP83867_PHY)  += dp83867.o
 obj-$(CONFIG_STE10XP)  += ste10Xp.o
 obj-$(CONFIG_MICREL_PHY)   += micrel.o
diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
new file mode 100644
index 000..5ce9bef
--- /dev/null
+++ b/drivers/net/phy/dp83848.c
@@ -0,0 +1,99 @@
+/*
+ * Driver for the Texas Instruments DP83848 PHY
+ *
+ * Copyright (C) 2015 Texas Instruments Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+
+#define DP83848_PHY_ID 0x20005c90
+
+/* Registers */
+#define DP83848_MICR   0x11
+#define DP83848_MISR   0x12
+
+/* MICR Register Fields */
+#define DP83848_MICR_INT_OEBIT(0) /* Interrupt Output Enable */
+#define DP83848_MICR_INTEN BIT(1) /* Interrupt Enable */
+
+/* MISR Register Fields */
+#define DP83848_MISR_RHF_INT_ENBIT(0) /* Receive Error Counter 
*/
+#define DP83848_MISR_FHF_INT_ENBIT(1) /* False Carrier Counter 
*/
+#define DP83848_MISR_ANC_INT_ENBIT(2) /* Auto-negotiation 
complete */
+#define DP83848_MISR_DUP_INT_ENBIT(3) /* Duplex Status */
+#define DP83848_MISR_SPD_INT_ENBIT(4) /* Speed status */
+#define DP83848_MISR_LINK_INT_EN   BIT(5) /* Link status */
+#define DP83848_MISR_ED_INT_EN BIT(6) /* Energy detect */
+#define DP83848_MISR_LQM_INT_ENBIT(7) /* Link Quality Monitor 
*/
+
+static int dp83848_ack_interrupt(struct phy_device *phydev)
+{
+   int err = phy_read(phydev, DP83848_MISR);
+
+   return err < 0 ? err : 0;
+}
+
+static int dp83848_config_intr(struct phy_device *phydev)
+{
+   int err;
+
+   if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
+   err = phy_write(phydev, DP83848_MICR,
+   DP83848_MICR_INT_OE |
+   DP83848_MICR_INTEN);
+   if (err < 0)
+   return err;
+
+   return phy_write(phydev, DP83848_MISR,
+DP83848_MISR_ANC_INT_EN |
+DP83848_MISR_DUP_INT_EN |
+DP83848_MISR_SPD_INT_EN |
+DP83848_MISR_LINK_INT_EN);
+   }
+
+   return phy_write(phydev, DP83848_MICR, 0x0);
+}
+
+static struct mdio_device_id __maybe_unused dp83848_tbl[] = {
+   { DP83848_PHY_ID, 0xfff0 },
+   { }
+};
+MODULE_DEVICE_TABLE(mdio, dp83848_tbl);
+
+static struct phy_driver dp83848_driver[] = {
+   {
+   .phy_id = DP83848_PHY_ID,
+   .phy_id_mask= 0xfff0,
+   .name   = "TI DP83848",
+   .features   = PHY_BASIC_FEATURES,
+   .flags  = PHY_HAS_INTERRUPT,
+
+   .soft_reset = genphy_soft_reset,
+   .config_init= genphy_config_init,
+   .suspend= genphy_suspend,
+   .resume = genphy_resume,
+

Re: [PATCH] net: phy: dp83848: Add TI DP83848 Ethernet PHY

2015-10-20 Thread Andrew F. Davis

On 10/20/2015 04:37 PM, Florian Fainelli wrote:

On 20/10/15 14:28, Andrew F. Davis wrote:

Add support for the TI DP83848 Ethernet PHY device.

The DP83848 is a highly reliable, feature rich, IEEE 802.3 compliant
single port 10/100 Mb/s Ethernet Physical Layer Transceiver supporting
the MII and RMII interfaces.

Signed-off-by: Andrew F. Davis <a...@ti.com>
Signed-off-by: Dan Murphy <dmur...@ti.com>


Reviewed-by: Florian Fainelli <f.faine...@gmail.com>

Just one comment below:

[snip]


diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 87f079c..b748224 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_MDIO_BITBANG)+= mdio-bitbang.o
  obj-$(CONFIG_MDIO_GPIO)   += mdio-gpio.o
  obj-$(CONFIG_NATIONAL_PHY)+= national.o
  obj-$(CONFIG_DP83640_PHY) += dp83640.o
+obj-$(CONFIG_DP83848_PHY)  += dp83848.o
  obj-$(CONFIG_DP83867_PHY) += dp83867.o


This is a pretty small PHY driver, would it make sense to look into
consolidating these into e.g: dp838xx.c for instance? dp83640 is big
enough to be its own driver it seems.



I was looking into that, but from the looks of it these drivers are small
because only the functions that differentiate the PHYs need be defined.
So there is very little common code between them.

I'm going to be brining up a couple more PHYs soon, so I'll keep this in mind
and try to find any redundancy that can be merged when working on these.

Thanks,
Andrew
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html