net: qcom/emac: simplify support for different SOCs
Subsystems (3)
v3 cover net: qcom/emac: simplify support for different SOCs
On SOCs that have the Qualcomm EMAC network controller, the internal PHY block is always different. Sometimes the differences are small, sometimes it might be a completely different IP. Either way, using version numbers to differentiate them and putting all of the init code in one file does not scale.
This patchset does two things: The first breaks up the current code into different files, and the second patch adds support for a third SOC, the Qualcomm Technologies QDF2400 ARM Server SOC.
Timur Tabi (2):
[v2] net: qcom/emac: move phy init code to separate files [v3] net: qcom/emac: add support for the Qualcomm Technologies QDF2400
drivers/net/ethernet/qualcomm/emac/Makefile | 4 +- .../ethernet/qualcomm/emac/emac-sgmii-fsm9900.c | 245 +++++++++ .../ethernet/qualcomm/emac/emac-sgmii-qdf2400.c | 217 ++++++++ .../ethernet/qualcomm/emac/emac-sgmii-qdf2432.c | 210 ++++++++ drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 569 ++------------------- drivers/net/ethernet/qualcomm/emac/emac-sgmii.h | 6 +- 6 files changed, 725 insertions(+), 526 deletions(-) create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-sgmii-fsm9900.c create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-sgmii-qdf2400.c create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-sgmii-qdf2432.c
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH v3 2/2 net: qcom/emac: add support for the Qualcomm Technologies QDF2400
The QDF2432 and the QDF2400 have slightly different internal PHYs, so there are some programming differences. Some of the registers in the QDF2400 have moved, and some registers require different values during initialization.
Because of the differences, and because HIDs are a scare resource, the ACPI tables specify the hardware version in an _HRV property. Version 1 is the QDF2432, and version 2 is the QDF2400. Any future SOC that has the same internal PHY but different programming requirements will be assigned the next available version number.
---
Notes:
v3: fix kbuild compilation error with !CONFIG_ACPI
drivers/net/ethernet/qualcomm/emac/Makefile | 3 +- .../ethernet/qualcomm/emac/emac-sgmii-qdf2400.c | 217 +++++++++++++++++++++ drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 33 +++- drivers/net/ethernet/qualcomm/emac/emac-sgmii.h | 1 + 4 files changed, 249 insertions(+), 5 deletions(-) create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-sgmii-qdf2400.c
drivers/net/ethernet/qualcomm/emac/Makefile +2 -1
@@ -5,4 +5,5 @@ obj-$(CONFIG_QCOM_EMAC) += qcom-emac.o qcom-emac-objs := emac.o emac-mac.o emac-phy.o emac-sgmii.o \ - emac-sgmii-fsm9900.o emac-sgmii-qdf2432.o + emac-sgmii-fsm9900.o emac-sgmii-qdf2432.o \ + emac-sgmii-qdf2400.o
drivers/net/ethernet/qualcomm/emac/emac-sgmii-qdf2400.c new file +217 -0
217 lines not on this page · raw message
drivers/net/ethernet/qualcomm/emac/emac-sgmii.c +29 -4
@@ -161,20 +161,45 @@ void emac_sgmii_reset(struct emac_adapter *adpt)static int emac_sgmii_acpi_match (struct device *dev,void *data) { +#ifdef CONFIG_ACPI static const struct acpi_device_id match_table[] = { { .id ="QCOM8071" , - .driver_data = (kernel_ulong_t )emac_sgmii_init_qdf2432, }, {} };const struct acpi_device_id *id =acpi_match_device (match_table, dev);emac_sgmii_initialize *initialize = data; -if (id) - *initialize = (emac_sgmii_initialize )id->driver_data; +if (id) { +acpi_handle handle =ACPI_HANDLE (dev); +unsigned long long hrv; +acpi_status status; + + status =acpi_evaluate_integer (handle,"_HRV" ,NULL , &hrv); +if (status) { +if (status ==AE_NOT_FOUND ) +/* Older versions of the QDF2432 ACPI tables do +* not have an _HRV property. +*/ + hrv =1 ; +else +/* Something is wrong with the tables */ +return 0 ; + } -return !!id; +switch (hrv) { +case 1 : + *initialize = emac_sgmii_init_qdf2432; +return 1 ; +case 2 : + *initialize = emac_sgmii_init_qdf2400; +return 1 ; + } + } +#endif + +return 0 ; }static const struct of_device_id emac_sgmii_dt_match[] = {
drivers/net/ethernet/qualcomm/emac/emac-sgmii.h +1 -0
@@ -21,5 +21,6 @@ void emac_sgmii_reset(struct emac_adapter *adpt);int emac_sgmii_init_fsm9900 (struct emac_adapter *adpt);int emac_sgmii_init_qdf2432 (struct emac_adapter *adpt); +int emac_sgmii_init_qdf2400 (struct emac_adapter *adpt);#endif
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH v2 1/2 net: qcom/emac: move phy init code to separate files
In reply to Timur TabiThe internal PHY of the EMAC differs on each SOC, and the list will only continue to grow. By separating the code into individual files, we can add support for more SOCs more cleanly.
Note: The internal PHY is also sometimes called the SGMII device.
We also stop referring to the various PHY variations by version number, so no more "v2", "v3", etc. Instead, the devices are named after the SOC they are, which is in sync with the device tree property names.
Future patches will probably rearrange more code among the files.
---
Notes:
v2: remove extraneous _v1
drivers/net/ethernet/qualcomm/emac/Makefile | 3 +- .../ethernet/qualcomm/emac/emac-sgmii-fsm9900.c | 245 ++++++++++ .../ethernet/qualcomm/emac/emac-sgmii-qdf2432.c | 210 ++++++++ drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 538 +-------------------- drivers/net/ethernet/qualcomm/emac/emac-sgmii.h | 5 +- 5 files changed, 478 insertions(+), 523 deletions(-) create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-sgmii-fsm9900.c create mode 100644 drivers/net/ethernet/qualcomm/emac/emac-sgmii-qdf2432.c
drivers/net/ethernet/qualcomm/emac/Makefile +2 -1
@@ -4,4 +4,5 @@ obj-$(CONFIG_QCOM_EMAC) += qcom-emac.o -qcom-emac-objs := emac.o emac-mac.o emac-phy.o emac-sgmii.o +qcom-emac-objs := emac.o emac-mac.o emac-phy.o emac-sgmii.o \ + emac-sgmii-fsm9900.o emac-sgmii-qdf2432.o
drivers/net/ethernet/qualcomm/emac/emac-sgmii-fsm9900.c new file +245 -0
245 lines not on this page · raw message
drivers/net/ethernet/qualcomm/emac/emac-sgmii-qdf2432.c new file +210 -0
210 lines not on this page · raw message
drivers/net/ethernet/qualcomm/emac/emac-sgmii.c +18 -520
604 lines not on this page · raw message
drivers/net/ethernet/qualcomm/emac/emac-sgmii.h +3 -2
@@ -16,9 +16,10 @@struct emac_adapter ;struct platform_device ; -int emac_sgmii_init_v1 (struct emac_adapter *adpt); -int emac_sgmii_init_v2 (struct emac_adapter *adpt);int emac_sgmii_config (struct platform_device *pdev,struct emac_adapter *adpt);void emac_sgmii_reset (struct emac_adapter *adpt); +int emac_sgmii_init_fsm9900 (struct emac_adapter *adpt); +int emac_sgmii_init_qdf2432 (struct emac_adapter *adpt); +#endif
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
David Miller
maintainerFrom: Timur Tabi <[email protected]>
Date: Thu, 8 Dec 2016 13:24:19 -0600
Quoted 9 lines
On SOCs that have the Qualcomm EMAC network controller, the internal PHY block is always different. Sometimes the differences are small, sometimes it might be a completely different IP. Either way, using version numbers to differentiate them and putting all of the init code in one file does not scale.
This patchset does two things: The first breaks up the current code into different files, and the second patch adds support for a third SOC, the Qualcomm Technologies QDF2400 ARM Server SOC.
Series applied.