Page MenuHomeFreeBSD

D13296.id35966.diff
No OneTemporary

D13296.id35966.diff

Index: sys/arm/allwinner/if_awg.c
===================================================================
--- sys/arm/allwinner/if_awg.c
+++ sys/arm/allwinner/if_awg.c
@@ -70,6 +70,7 @@
#include <dev/extres/hwreset/hwreset.h>
#include <dev/extres/regulator/regulator.h>
+#include "syscon_if.h"
#include "miibus_if.h"
#include "gpio_if.h"
@@ -105,6 +106,7 @@
#define RX_BATCH_DEFAULT 64
/* syscon EMAC clock register */
+#define EMAC_CLK_REG 0x30
#define EMAC_CLK_EPHY_ADDR (0x1f << 20) /* H3 */
#define EMAC_CLK_EPHY_ADDR_SHIFT 20
#define EMAC_CLK_EPHY_LED_POL (1 << 17) /* H3 */
@@ -186,7 +188,6 @@
enum {
_RES_EMAC,
_RES_IRQ,
- _RES_SYSCON,
_RES_NITEMS
};
@@ -203,6 +204,7 @@
int link;
int if_flags;
enum awg_type type;
+ device_t syscon;
struct awg_txring tx;
struct awg_rxring rx;
@@ -211,7 +213,6 @@
static struct resource_spec awg_spec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
{ SYS_RES_IRQ, 0, RF_ACTIVE },
- { SYS_RES_MEMORY, 1, RF_ACTIVE | RF_OPTIONAL },
{ -1, 0 }
};
@@ -1172,10 +1173,10 @@
if (bootverbose)
device_printf(dev, "PHY type: %s, conf mode: %s\n", phy_type,
- sc->res[_RES_SYSCON] != NULL ? "reg" : "clk");
+ sc->syscon != NULL ? "reg" : "clk");
- if (sc->res[_RES_SYSCON] != NULL) {
- reg = bus_read_4(sc->res[_RES_SYSCON], 0);
+ if (sc->syscon != NULL) {
+ reg = SYSCON_READ_4(sc->syscon, dev, EMAC_CLK_REG);
reg &= ~(EMAC_CLK_PIT | EMAC_CLK_SRC | EMAC_CLK_RMII_EN);
if (strcmp(phy_type, "rgmii") == 0)
reg |= EMAC_CLK_PIT_RGMII | EMAC_CLK_SRC_RGMII;
@@ -1215,7 +1216,7 @@
if (bootverbose)
device_printf(dev, "EMAC clock: 0x%08x\n", reg);
- bus_write_4(sc->res[_RES_SYSCON], 0, reg);
+ SYSCON_WRITE_4(sc->syscon, dev, EMAC_CLK_REG, reg);
} else {
if (strcmp(phy_type, "rgmii") == 0)
tx_parent_name = "emac_int_tx";
@@ -1713,14 +1714,22 @@
{
uint8_t eaddr[ETHER_ADDR_LEN];
struct awg_softc *sc;
- phandle_t node;
- int error;
+ phandle_t node, syscon_xref;
+ int error, len;
sc = device_get_softc(dev);
sc->dev = dev;
sc->type = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
+ sc->syscon = NULL;
node = ofw_bus_get_node(dev);
+ if (OF_hasprop(node, "syscon")) {
+ len = OF_getencprop(node, "syscon", &syscon_xref,
+ sizeof(syscon_xref));
+ if (len > 0)
+ sc->syscon = OF_device_from_xref(syscon_xref);
+ }
+
if (bus_alloc_resources(dev, awg_spec, sc->res) != 0) {
device_printf(dev, "cannot allocate resources for device\n");
return (ENXIO);

File Metadata

Mime Type
text/plain
Expires
Fri, Jul 3, 10:28 AM (15 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34620289
Default Alt Text
D13296.id35966.diff (2 KB)

Event Timeline